Esempio n. 1
0
        public void AddToCartElementByIndex(int index)
        {
            List <DomElement> items = catalogSummary.GetElementsWaitByCSS(displayedButtonItems.locator);

            if (index > items.Count - 1 || index < 0)
            {
                index = items.Count - 1;
            }
            base.ScrollToTop();
            //this do while repeats the click if the page doesn't get selenium's click
            do
            {
                try
                {
                    Thread.Sleep(1000);
                    items[index].webElement.Click();
                }
                catch (Exception)
                {
                    Thread.Sleep(1000);
                    items = catalogSummary.GetElementsWaitByCSS(displayedButtonItems.locator);
                    items[index].webElement.Click();
                }
                DomElement miniCart = catalogSummary.GetElementWaitUntilByXpath(this.miniCart.locator, (el) => el.Displayed);
            } while (miniCart.webElement != null);
            //this line waits until mini cart is no longer visible
            catalogSummary.GetElementWaitUntilByXpath(this.miniCart.locator, (el) => el.Displayed == false);
            //*********
        }
Esempio n. 2
0
        protected List <DomElement> GetDropdownAutoCompleteOptions(DomElement dropdown)
        {
            dropdown.webElement.Click();

            List <DomElement> options = dropdown.GetElementsWaitByCSS(".ui-select-choices-row-inner");

            return(options);
        }
Esempio n. 3
0
        public List <string> GetManufacturerMenuOptionsText()
        {
            DomElement searchContainer = SecondarySearchContainer.GetElementWaitByCSS(ProductSearchContainer.locator);
            DomElement select          = searchContainer.GetElementWaitByCSS(ProductSearchContainerManufacturerSelect.locator);

            select.webElement.Click();
            return(select.GetElementsWaitByCSS(ProductSearchContainerManufacturerSelectItem.locator).Select(el => el.webElement.Text).ToList());
        }
Esempio n. 4
0
        public virtual int NumberOfItemsInList()
        {
            base.WaitForAppBusy(6);
            Thread.Sleep(2000);
            List <DomElement> listItems = detailSummary.GetElementsWaitByCSS(itemInList.locator);

            return(listItems.Count);
        }
Esempio n. 5
0
        private void SelectBillingRadioButtonByOptionText(string optionText)
        {
            DomElement        billingForm    = detailSummary.GetElementWaitByCSS(detailBillingSection.locator);
            DomElement        billingInput   = billingForm.GetElementWaitByCSS(detailBillingEditFormInput.locator);
            List <DomElement> radioOptions   = billingInput.GetElementsWaitByCSS(detailBillingEditFormInputRadio.locator);
            DomElement        choosenElement = radioOptions.Where(o => o.webElement.Text.Contains(optionText)).FirstOrDefault();

            choosenElement.locator = choosenElement.locator.Replace("(2)", "(3)");
            choosenElement.GetElementWaitByCSS("label").webElement.Click();
        }
Esempio n. 6
0
        public void SetManufacturerDropdown(string manufacturer)
        {
            DomElement searchContainer = SecondarySearchContainer.GetElementWaitByCSS(ProductSearchContainer.locator);
            DomElement select          = searchContainer.GetElementWaitByCSS(ProductSearchContainerManufacturerSelect.locator);

            select.webElement.Click();
            DomElement selectedManufacturer = select.GetElementsWaitByCSS("option").FirstOrDefault((e => e.webElement.Text == manufacturer));

            selectedManufacturer.webElement.Click();
        }
Esempio n. 7
0
        public APIndexPage ContinueShoppingClick()
        {
            //Due to have same class for both buttons, we need to create a List and select by name (label)
            List <DomElement> detailActionButtons = detailNavSection.GetElementsWaitByCSS(detailContinueShoppingBtn.locator);
            DomElement        detailContinueBtn   = detailActionButtons.FirstOrDefault(el => el.webElement.Text == "Continue Shopping");

            Thread.Sleep(5000);
            detailContinueBtn.webElement.Click();
            return(new APIndexPage(Driver, true));
        }
Esempio n. 8
0
        public OfferingProductsPage ClickOnProductSpotlightDealsByIndex(int index)
        {
            List <DomElement> productsSpotlightDeals = mainBodySummary.GetElementsWaitByCSS(this.productSpotlightDeals.locator);

            if (index > productsSpotlightDeals.Count - 1 || index < 0)
            {
                index = productsSpotlightDeals.Count - 1;
            }
            productsSpotlightDeals[index].webElement.Click();
            return(new OfferingProductsPage(Driver));
        }
Esempio n. 9
0
        public virtual void SelectFirstInBillingDropDown()
        {
            DomElement billingForm     = detailSummary.GetElementWaitByCSS(detailBillingSection.locator);
            DomElement billingDropDown = billingForm.GetElementWaitByCSS(detailBillingEditFormInputExistingDropdown.locator);

            billingDropDown.webElement.Click();
            DomElement        billingOnlyDropdown = billingForm.GetElementWaitByCSS(detailBillingEditFormInputExistingDropdownOnly.locator);
            List <DomElement> dropdownOptions     = billingOnlyDropdown.GetElementsWaitByCSS(detailBillingEditFormInputExistingDropdownOption.locator);

            dropdownOptions.FirstOrDefault().webElement.Click();
        }
Esempio n. 10
0
        public bool OrderResultTableHaveValues()
        {
            searchResultTable.Init(Driver, SeleniumConstants.defaultWaitTime);
            searchResultTableOrders = searchResultTable.GetElementWaitByCSS(searchResultTableOrders.locator);
            List <DomElement> orders = searchResultTableOrders.GetElementsWaitByCSS("tr");

            if (orders.Count > 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 11
0
        protected void SelectDropDownOption(DomElement dropdown, string optionText)
        {
            List <DomElement> searchOptions = dropdown.GetElementsWaitByCSS("option");
            DomElement        option        = searchOptions.FirstOrDefault(o => o.webElement.Text.Contains(optionText));

            if (option == null)
            {
                throw new NotFoundException($"{optionText} is not found");
            }

            option.webElement.Click();
        }
Esempio n. 12
0
        public virtual void SelectFirstInAddressDropDown()
        {
            DomElement shippingForm    = detailSummary.GetElementWaitByCSS(detailShippingSection.locator);
            DomElement addressInput    = shippingForm.GetElementWaitByCSS(detailShippingEditFormInput.locator);
            DomElement addressDropDown = addressInput.GetElementWaitByCSS(detailShippingEditFormInputExistingDropdown.locator);

            addressDropDown.webElement.Click();
            Thread.Sleep(2000);
            List <DomElement> dropdownOptions = addressDropDown.GetElementsWaitByCSS(detailShippingEditFormInputExistingDropdownOption.locator);

            dropdownOptions.FirstOrDefault().webElement.Click();
        }
Esempio n. 13
0
        public List <CartProductItem> GetProductItems()
        {
            List <CartProductItem> itemsNamesCollection = new List <CartProductItem>();
            DomElement             cartContainer        = BodyContainer.GetElementWaitByCSS(Container.locator);
            DomElement             detailSection        = cartContainer.GetElementWaitByCSS(DetailSection.locator);
            DomElement             itemsContainer       = detailSection.GetElementWaitByCSS(CartItemsSection.locator);
            List <DomElement>      items = itemsContainer.GetElementsWaitByCSS(CartItem.locator);

            foreach (var item in items)
            {
                itemsNamesCollection.Add(new CartProductItem(Driver, item));
            }
            return(itemsNamesCollection);
        }
Esempio n. 14
0
        private DomElement GetMenuItemByHover(DomElement menu, string menuItemText)
        {
            HoverWebElement(menu);

            List <DomElement> menuItems = menu.GetElementsWaitByCSS("li:not(.divider)");

            DomElement foundItem = menuItems.FirstOrDefault(item => item.webElement.Text.Contains(menuItemText));

            if (foundItem == null)
            {
                throw new NotFoundException($"Menu item, '{menuItemText}' is not found");
            }

            return(foundItem);
        }
Esempio n. 15
0
        public List <CheckoutProductItem> GetProductItems()
        {
            List <CheckoutProductItem> productItems = new List <CheckoutProductItem>();
            DomElement        container             = BodyContainer.GetElementWaitByCSS(Container.locator);
            DomElement        checkoutItemsSection  = container.GetElementWaitByCSS(CheckoutItemsSection.locator);
            DomElement        itemsGridSection      = checkoutItemsSection.GetElementWaitByCSS(ItemsGridSection.locator);
            List <DomElement> items = itemsGridSection.GetElementsWaitByCSS(CheckoutProductItem.locator);

            foreach (var item in items)
            {
                productItems.Add(new CheckoutProductItem(Driver, item));
            }

            return(productItems);
        }
Esempio n. 16
0
        public List <ProductItemOffering> GetResultItems()
        {
            List <ProductItemOffering> itemsNamesCollection = new List <ProductItemOffering>();

            SectionContainer = BodyContainer.GetElementWaitByCSS(SectionContainer.locator);
            DomElement        divContainer = SectionContainer.GetElementWaitByCSS(ItemsGridDivContainer.locator);
            DomElement        ulContainer  = divContainer.GetElementWaitByCSS(ItemsGridUlContainer.locator);
            List <DomElement> items        = ulContainer.GetElementsWaitByCSS(SingleGridItem.locator);

            foreach (var item in items)
            {
                itemsNamesCollection.Add(new ProductItemOffering(Driver, item));
            }
            return(itemsNamesCollection);
        }
Esempio n. 17
0
        // method that returns if all the shipping options are priced or not
        public bool ShippingOptionsPriced()
        {
            DomElement        detailrightnavMenu       = rightNavMenu.GetElementWaitByCSS(rightNavShippingSection.locator);
            DomElement        detailShippingSection    = detailrightnavMenu.GetElementWaitByCSS(rightNavShippingRates.locator);
            List <DomElement> detailShippingRatesPrice = detailShippingSection.GetElementsWaitByCSS(rightNavShippingRate.locator);

            foreach (DomElement item in detailShippingRatesPrice)
            {
                double value = -1;
                double.TryParse(item.webElement.Text.Replace("$", ""), out value);
                if (value == -1)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 18
0
        public void MoveSelectedToCart()
        {
            base.ScrollToTop();
            try
            {
                DomElement moveSelectedToCartElement = detailSummary.GetElementWaitByCSS(moveSelectedToCart.locator);
                moveSelectedToCartElement.webElement.Click();
            }
            catch (Exception)
            {
                DomElement dropdownActionsContainer = detailSummary.GetElementWaitByCSS(this.dropDownActionsContainer.locator);
                dropdownActionsContainer.GetElementWaitByCSS(this.dropdownActionsButton.locator).webElement.Click();
                List <DomElement> items = dropdownActionsContainer.GetElementsWaitByCSS(this.dropDwonActionsItem.locator);
                items[2].webElement.Click();
            }

            base.WaitForAppBusy(8);
        }
Esempio n. 19
0
        public IEnumerable <string> GetColumn(string columnName)
        {
            DomElement column = Container.GetElementsWaitByCSS("thead th").FirstOrDefault(th => th.webElement.Text.Contains(columnName));

            if (column == null)
            {
                throw new NotFoundException($"Column: {columnName} is not found");
            }

            int i = Container.GetElementsWaitByCSS("thead th").FindIndex(th => th.webElement.Text.Contains(columnName));

            return(GetColumn(i + 1));
        }
Esempio n. 20
0
        public void ClickRemoveSelectedItems()
        {
            base.ScrollToTop();
            try
            {
                DomElement removeSelectedFromCartButton = detailSummary.GetElementWaitByCSS(this.removeSelectedFromCartButton.locator);
                removeSelectedFromCartButton.webElement.Click();
            }
            catch (Exception)
            {
                Thread.Sleep(2500);
                DomElement dropdownActionsContainer = detailSummary.GetElementWaitByCSS(this.dropDownActionsContainer.locator);
                dropdownActionsContainer.GetElementWaitByCSS(this.dropdownActionsButton.locator).webElement.Click();
                List <DomElement> items = dropdownActionsContainer.GetElementsWaitByCSS(this.dropDwonActionsItem.locator);
                items[2].webElement.Click();
            }

            base.WaitForAppBusy(8);
        }
Esempio n. 21
0
        public void SelectBillingAddressOption(BillingAddressOptionsEnum selectedOption)
        {
            DomElement formContainer = DetailSection.GetElementWaitByCSS(DetailSectionCardTokenForm.locator);
            DomElement billingAddressOptionsContainer = formContainer.GetElementWaitByCSS(BillingAddressOptionsContainer.locator);
            var        options = billingAddressOptionsContainer.GetElementsWaitByCSS(BillingAddressOptionItem.locator);

            switch (selectedOption)
            {
            case BillingAddressOptionsEnum.AddNew:
                options.FirstOrDefault(x => x.webElement.Text.Contains("Assign a new address")).webElement.Click();
                break;

            case BillingAddressOptionsEnum.Stored:
                options.FirstOrDefault(x => x.webElement.Text.Contains("Use a previously stored address")).webElement.Click();
                break;

            default:
                throw new ArgumentException($"{selectedOption} is not valid");
            }
        }
Esempio n. 22
0
        public IDictionary <string, string> AvailabiltyTagGet()
        {
            IDictionary <string, string> dict  = new Dictionary <string, string>();
            DomElement        cartItemsSection = detailSummary.GetElementWaitByCSS(detailCartItems.locator);
            List <DomElement> cartItems        = cartItemsSection.GetElementsWaitByCSS(detailCartItem.locator);

            foreach (var item in cartItems)
            {
                //Get Cart Item Sku
                DomElement itemContent = item.GetElementWaitByCSS(detailCartItemContent.locator);
                DomElement itemProduct = itemContent.GetElementWaitByCSS(detailCartItemContentProduct.locator);
                DomElement itemSku     = itemProduct.GetElementWaitByCSS(detailCartItemContentProductSKU.locator);

                //Get Cart Item Availabilty Tag
                DomElement itemAvailabilty   = item.GetElementWaitByCSS(detailCartItemAvailability.locator);
                DomElement itemAvailabilyTag = itemAvailabilty.GetElementWaitByCSS(detailCartItemAvailabilityTag.locator);
                dict.Add(itemSku.webElement.Text, itemAvailabilyTag.webElement.Text);
            }

            return(dict);
        }
Esempio n. 23
0
        public string SelectShipping(string shipMethod)
        {
            DomElement        detailrightnavMenu    = rightNavMenu.GetElementWaitByCSS(rightNavShippingSection.locator);
            DomElement        detailShippingSection = detailrightnavMenu.GetElementWaitByCSS(rightNavShippingRates.locator);
            List <DomElement> detailShippingRates   = detailShippingSection.GetElementsWaitByCSS("div.line");

            foreach (DomElement item in detailShippingRates)
            {
                if (item.GetElementWaitByCSS("input + span").webElement.Text.Equals(shipMethod))
                {
                    // TEMPORARY fix for clicks to work on shipping inputs
                    IJavaScriptExecutor jse2 = (IJavaScriptExecutor)Driver;
                    jse2.ExecuteScript("arguments[0].click();", item.GetElementWaitByCSS("input").webElement);

                    //item.GetElementWaitByCSS("input").webElement.Click();

                    return(item.GetElementWaitByCSS("div.value span").webElement.Text);
                }
            }

            return("");
        }
Esempio n. 24
0
        public void AddToCartPartNumber(string partNumber)
        {
            iFrame = Driver.SwitchTo().Frame(FrameName);
            TableParts.Init(iFrame, SeleniumConstants.defaultWaitTime);
            //IWebElement partsTable = iFrame.FindElement(By.CssSelector(TableParts.locator));
            List <DomElement> rows = TableParts.GetElementsWaitByCSS("tr");

            int columnNum = GetColumnForHeader(rows, "PART #");
            int rowNum    = GetRowNumberForItem(rows, columnNum, partNumber);

            //rows[rowNum - 1].GetElementWaitByCSS("td > div.gridconqty input").webElement.Click();

            var addBtn = rows[rowNum - 1].GetElementWaitByCSS("td > div.gridconqty input").webElement;

            if (addBtn == null)
            {
                throw new NotFoundException($"{partNumber} is not found in the table");
            }

            addBtn.Click();

            Driver.SwitchTo().Window(parentWindow);
        }
Esempio n. 25
0
        protected List <DomElement> GetDropdownOptions(DomElement dropdown)
        {
            dropdown.webElement.Click();

            return(dropdown.GetElementsWaitByCSS("option"));
        }
Esempio n. 26
0
        public virtual int GetNumberOfLists()
        {
            List <DomElement> items = detailSummary.GetElementsWaitByCSS(this.listItem.locator);

            return(items.Count);
        }
Esempio n. 27
0
        public ICollection <string> GetColumns(int nCol)
        {
            var cols = Table.GetElementsWaitByCSS($"tbody tr td:nth-child({nCol})").Select(el => el.webElement.Text);

            return(cols.ToList());
        }
Esempio n. 28
0
 private List <DomElement> GetSelectedItems()
 {
     return(detailSummary.GetElementsWaitByCSS(selectedSpan.locator));
 }