/// <summary>
        /// Opens the drop down and returns the option.
        /// </summary>
        /// <param name="optionText">The option.</param>
        /// <param name="stringComparison">The string comparison.</param>
        /// <returns></returns>
        /// <exception cref="NoSuchElementException"></exception>
        public virtual MenuItemComponent SelectOption(string optionText,
                                                      StringComparison stringComparison = StringComparison.Ordinal)
        {
            // This isn't ideal but since the dropdown menu items are
            // generated on the first time the parent menu item is clicked,
            // click the parent element, wait 500 ms (should be enough time for
            // the dropdown to be generated), and move the mouse below the
            // parent element to locate the dropdown container.
            WrappedElement.Click();
            Thread.Sleep(500);

            // Determine where the float-menu will appear. Usually it's either
            // directly below or to the right.
            var(X, Y) = GetDirectionFloatMenuWillOpen();

            // Move below the WrappedElement.
            WrappedDriver.CreateActions()
            .MoveToElement(
                toElement: WrappedElement,
                offsetX: X,
                offsetY: Y,
                offsetOrigin: MoveToElementOffsetOrigin.Center)
            .Perform();

            // Get the container element under the mouse.
            var focusedElement = WrappedDriver
                                 .GetHoveredElements(allMenuDropDownsSelector)
                                 .First();

            var menuItemEl = focusedElement.FindElements(dropDownItemsSelector)
                             .FirstOrDefault(el =>
            {
                var textEl = el.FindElements(textSelector)
                             .FirstOrDefault();

                return(textEl == null
                        ? false
                        : String.Equals(
                           textEl.TextHelper().InnerText,
                           optionText,
                           stringComparison));
            });

            if (menuItemEl == null)
            {
                throw new NoSuchElementException();
            }

            var selector = ByElement.FromElement(menuItemEl);

            return(PageObjectFactory.PrepareComponent(
                       new MenuItemComponent(
                           selector,
                           PageObjectFactory,
                           WrappedDriver)));
        }
Beispiel #2
0
 /// <summary>
 /// Retrieves the wishlist items.
 /// </summary>
 /// <returns></returns>
 /// <exception cref="NotImplementedException"></exception>
 public virtual IEnumerable <WishlistRowComponent> GetItems()
 {
     foreach (var item in RowElements)
     {
         yield return(pageObjectFactory.PrepareComponent(
                          new WishlistRowComponent(
                              ByElement.FromElement(item),
                              pageObjectFactory,
                              WrappedDriver)));
     }
 }
        /// <summary>
        /// Gets the cart item.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <returns></returns>
        public virtual OrderSummaryRowComponent GetCartItem(int index)
        {
            var el        = CartRowElements.ElementAt(index);
            var component = pageObjectFactory.PrepareComponent(
                new OrderSummaryRowComponent(
                    ByElement.FromElement(el),
                    pageObjectFactory,
                    WrappedDriver));

            return(component);
        }
 /// <summary>
 /// Gets the items.
 /// </summary>
 /// <returns></returns>
 public virtual IEnumerable <IAdminMainSideBarNodeComponent> GetItems()
 {
     foreach (var el in ParentTreeElement.Children())
     {
         yield return(pageObjectFactory.PrepareComponent(
                          new AdminMainSideBarNodeComponent(
                              ByElement.FromElement(el),
                              null,
                              pageObjectFactory,
                              WrappedDriver)));
     }
 }
Beispiel #5
0
        /// <summary>
        /// Gets the products.
        /// </summary>
        /// <returns></returns>
        public virtual IEnumerable <OrderSummaryReadOnlyRowComponent> GetProducts()
        {
            var rowEls = WrappedDriver.FindElements(productRowsSelector);

            foreach (var rowEl in rowEls)
            {
                yield return(pageObjectFactory.PrepareComponent(
                                 new OrderSummaryReadOnlyRowComponent(
                                     ByElement.FromElement(rowEl),
                                     WrappedDriver)));
            }
        }
Beispiel #6
0
 /// <summary>
 /// Gets the orders.
 /// </summary>
 /// <returns></returns>
 public virtual IEnumerable <CustomerOrderRowComponent> GetOrders()
 {
     foreach (var row in OrderRowElements)
     {
         yield return(pageObjectFactory.PrepareComponent(
                          new CustomerOrderRowComponent(
                              ByElement.FromElement(row),
                              this,
                              pageObjectFactory,
                              WrappedDriver)));
     }
 }
 /// <summary>
 /// Gets the addresses.
 /// </summary>
 /// <returns></returns>
 public virtual IEnumerable <AddressesRowComponent <IAddressesPage> > GetAddresses()
 {
     foreach (var row in AddressRowElements)
     {
         yield return(pageObjectFactory.PrepareComponent(
                          new AddressesRowComponent <IAddressesPage>(
                              ByElement.FromElement(row),
                              pageObjectFactory,
                              WrappedDriver,
                              this)));
     }
 }
        /// <summary>
        /// Gets the cart items.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public virtual IList <OrderSummaryRowComponent> GetCartItems()
        {
            var rowComponents = CartRowElements
                                .Select(e => pageObjectFactory.PrepareComponent(
                                            new OrderSummaryRowComponent(
                                                ByElement.FromElement(e),
                                                pageObjectFactory,
                                                WrappedDriver)))
                                .ToList();

            return(rowComponents);
        }