Example #1
0
        public List <SortedDictionary <string, string> > DomainNamesForHosting(string hostingType, SortedDictionary <string, string> dicFromHosting, SortedDictionary <string, string> dicWithDomainDetails, string domainselection = "")
        {
            string getUrl = BrowserInit.Driver.Url;

            if (!(BrowserInit.Driver.Url.Contains("domainselection.aspx") || BrowserInit.Driver.Url.Contains("wordpress.aspx")))
            {
                BrowserInit.Driver.Navigate().GoToUrl(getUrl);
            }

            var domainOptionListCount = PageInitHelper <DomainSelectionPageFactory> .PageInit.DomainOptionsLst.Count;
            int domainOptionsLst      = //domainselection.Equals("true")
                                        //? PageInitHelper<PageValidationHelper>.PageInit.RandomGenrator(domainOptionListCount) :
                                        domainOptionListCount;

            var listDicHostingProduct = new List <SortedDictionary <string, string> >();

            for (int i = 1; i <= domainOptionsLst; i++)
            {
                if (!(BrowserInit.Driver.Url.Contains("domainselection.aspx") || BrowserInit.Driver.Url.Contains("wordpress.aspx")))
                {
                    BrowserInit.Driver.Navigate().GoToUrl(getUrl);
                }
                //if (domainselection.Equals("true")) i = domainOptionsLst;

                string domainOptionsLstXpath    = "(.//*[contains(@class,'domain-select-options')]//a)[" + i + "]";
                var    domainCategory           = BrowserInit.Driver.FindElement(By.XPath(domainOptionsLstXpath));
                var    domainSelectionOptionTxt = domainCategory.Text.Trim();

                if (!domainselection.Equals(string.Empty))
                {
                    if (!domainSelectionOptionTxt.Contains(domainselection))
                    {
                        continue;
                    }
                }

                var dicDomainDetails = new SortedDictionary <string, string>();
                var listDic          = new List <Tuple <string, string, string, decimal, decimal> >();
                if (!BrowserInit.Driver.Url.Contains("domainselection.aspx"))
                {
                    BrowserInit.Driver.Navigate().GoToUrl(getUrl);
                }

                domainCategory.Click();
                IDomainSelectOptions selectDomain;

                if (domainSelectionOptionTxt.Contains(UiConstantHelper.CartDomain))
                {
                    selectDomain = new DomainInCart();
                    listDic      = selectDomain.HostingDomainSelection(dicWithDomainDetails);
                }
                else if (domainSelectionOptionTxt.Contains(UiConstantHelper.FreeDomain))
                {
                    selectDomain = new FreeDomain();
                    listDic      = selectDomain.HostingDomainSelection(dicFromHosting);
                }
                else if (domainSelectionOptionTxt.Contains(UiConstantHelper.NewDomain))
                {
                    selectDomain = new PurchaseNewDomain();
                    listDic      = selectDomain.HostingDomainSelection();
                }
                else if (domainSelectionOptionTxt.Contains(UiConstantHelper.NcDomain))
                {
                    selectDomain = new UseDomainWithNc();
                    listDic      = selectDomain.HostingDomainSelection();
                }
                else if (domainSelectionOptionTxt.Contains(UiConstantHelper.AnotherRegistrarDomain))
                {
                    selectDomain = new UseDomainFromOtherRegister();
                    listDic      = selectDomain.HostingDomainSelection();
                }
                else if (domainSelectionOptionTxt.Contains(UiConstantHelper.TransferDomainToNc))
                {
                    selectDomain = new TransferDomainFromanotherRegistrar();
                    listDic      = selectDomain.HostingDomainSelection();
                }

                foreach (var list in listDic)
                {
                    string  dname     = list.Item1;
                    string  duration  = list.Item2;
                    string  promocode = list.Item3;
                    decimal price     = list.Item4;
                    decimal regprice  = list.Item5;

                    dicDomainDetails.Add(EnumHelper.DomainKeys.DomainName.ToString(), dname);
                    dicDomainDetails.Add(EnumHelper.DomainKeys.DomainDuration.ToString(), duration);
                    dicDomainDetails.Add(EnumHelper.DomainKeys.DomainNamePromotionCode.ToString(), promocode);
                    dicDomainDetails.Add(EnumHelper.DomainKeys.DomainPrice.ToString(), price.ToString(CultureInfo.InvariantCulture));
                    dicDomainDetails.Add(EnumHelper.DomainKeys.DomainRetailPrice.ToString(), regprice.ToString(CultureInfo.InvariantCulture));
                }
                MergeSortedDictionary(dicFromHosting, dicDomainDetails);

                if (!(hostingType.Equals("Migrate to Namecheap") || hostingType.Equals("Shared Hosting")))
                {
                    PageInitHelper <CartWidgetPageFactory> .PageInit.ViewCartButton.Click();
                }


                ICartValidation cartValidation = new ProductListCartValidation();
                var             diccartWidget  = cartValidation.CartWidgetValidation(dicDomainDetails);

                if (!PageInitHelper <CartWidgetPageFactory> .PageInit.ShoppingCartHeadingTxt.Text.Trim().Equals("Shopping Cart"))
                {
                    PageInitHelper <PageNavigationHelper> .PageInit.ScrollToElement(PageInitHelper <CartWidgetPageFactory> .PageInit.ViewCartButton);

                    PageInitHelper <CartWidgetPageFactory> .PageInit.ViewCartButton.Click();
                }

                MergeSortedDictionary(dicDomainDetails, diccartWidget);

                listDicHostingProduct.Add(diccartWidget);
                if (!domainselection.Equals(string.Empty))
                {
                    return(listDicHostingProduct);
                }
            }
            return(listDicHostingProduct);
        }
        public List <SortedDictionary <string, string> > AddingPremiumDnsWithDomainNamesToCart(string purchasingDomainFor)
        {
            var listPremiumDnsProductDetails = new List <SortedDictionary <string, string> >();
            var dicPremiumDnsProducttDetails = new SortedDictionary <string, string>();
            var priceDurationTxt             = Regex.Split(
                PageInitHelper <PremiumDnsPageFactory> .PageInit.PremiunDnsProductPriceTxt.Text, "/");
            var premiunDnsProductPrice    = Regex.Replace(priceDurationTxt[0], @"[^\d..][^\w\s]*", "");
            var premiunDnsProductDuration = "1 " + priceDurationTxt[1].Replace(priceDurationTxt[1], "year");

            dicPremiumDnsProducttDetails.Add(EnumHelper.Ssl.PremiumDnsPrice.ToString(), premiunDnsProductPrice);
            dicPremiumDnsProducttDetails.Add(EnumHelper.Ssl.PremiumDnsDuration.ToString(),
                                             premiunDnsProductDuration);
            PageInitHelper <PremiumDnsPageFactory> .PageInit.PremiunDnsProductAddToCartBtn.Click();

            List <Tuple <string, string, string, decimal, decimal> > premiumDnsTupleList;
            IDomainSelectOptions domainSelectOption;
            ICartValidation      cartWidgetValidation;
            List <SortedDictionary <string, string> > mergedSearchdDomainAndCartWidgetList;

            switch (EnumHelper.ParseEnum <EnumHelper.DomainModuleSelection>(purchasingDomainFor))
            {
            case EnumHelper.DomainModuleSelection.NewDomain:
                domainSelectOption  = new PurchaseNewDomain();
                premiumDnsTupleList = domainSelectOption.HostingDomainSelection(dicPremiumDnsProducttDetails);
                foreach (var newDomains in premiumDnsTupleList)
                {
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainName.ToString(),
                                                     newDomains.Item1);
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainDuration.ToString(),
                                                     newDomains.Item2);
                    dicPremiumDnsProducttDetails.Add(
                        EnumHelper.DomainKeys.DomainNamePromotionCode.ToString(), newDomains.Item3);
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainPrice.ToString(),
                                                     newDomains.Item4.ToString(CultureInfo.InvariantCulture));
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainRetailPrice.ToString(),
                                                     newDomains.Item5.ToString(CultureInfo.InvariantCulture));
                    listPremiumDnsProductDetails.Add(dicPremiumDnsProducttDetails);
                }
                BrowserInit.Driver.FindElement(By.XPath("//*[@class='btn domain-select-new-btn']")).Click();
                Func <IWebDriver, bool> testCondition =
                    x => PageInitHelper <DomainSelectionPageFactory> .PageInit.CartContinueWidgetBtn.Enabled;
                var wait = new WebDriverWait(BrowserInit.Driver, TimeSpan.FromMinutes(5));
                wait.Until(testCondition);
                cartWidgetValidation = new ProductListCartValidation();
                mergedSearchdDomainAndCartWidgetList =
                    cartWidgetValidation.CartWidgetValidation(listPremiumDnsProductDetails);
                break;

            case EnumHelper.DomainModuleSelection.NcDomain:
                domainSelectOption  = new UseDomainWithNc();
                premiumDnsTupleList = domainSelectOption.HostingDomainSelection(dicPremiumDnsProducttDetails);
                foreach (var newDomains in premiumDnsTupleList)
                {
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainName.ToString(),
                                                     newDomains.Item1);
                    dicPremiumDnsProducttDetails.Add(
                        EnumHelper.ShoppingCartKeys.PremiumDnsForDomainStatus.ToString(), "ON");
                    listPremiumDnsProductDetails.Add(dicPremiumDnsProducttDetails);
                }
                cartWidgetValidation = new ProductListCartValidation();
                mergedSearchdDomainAndCartWidgetList =
                    cartWidgetValidation.CartWidgetValidation(listPremiumDnsProductDetails);
                break;

            case EnumHelper.DomainModuleSelection.AnotherRegistrarDomain:
                domainSelectOption  = new UseDomainFromOtherRegister();
                premiumDnsTupleList = domainSelectOption.HostingDomainSelection(dicPremiumDnsProducttDetails);
                foreach (var newDomains in premiumDnsTupleList)
                {
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainName.ToString(),
                                                     newDomains.Item1);
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainDuration.ToString(),
                                                     newDomains.Item2);
                    dicPremiumDnsProducttDetails.Add(
                        EnumHelper.DomainKeys.DomainNamePromotionCode.ToString(), newDomains.Item3);
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainPrice.ToString(),
                                                     newDomains.Item4.ToString(CultureInfo.InvariantCulture));
                    dicPremiumDnsProducttDetails.Add(EnumHelper.DomainKeys.DomainRetailPrice.ToString(),
                                                     newDomains.Item5.ToString(CultureInfo.InvariantCulture));
                    listPremiumDnsProductDetails.Add(dicPremiumDnsProducttDetails);
                }
                cartWidgetValidation = new ProductListCartValidation();
                mergedSearchdDomainAndCartWidgetList =
                    cartWidgetValidation.CartWidgetValidation(listPremiumDnsProductDetails);
                break;

            default:
                throw new IndexOutOfRangeException(purchasingDomainFor +
                                                   " Options is not available in a switch case statement on class name - 'PremiumDns' under method name - 'AddingPremiumDnsWithDomainNamesToCart'");
            }
            return(mergedSearchdDomainAndCartWidgetList);
        }