Beispiel #1
0
        /// <summary>
        /// Selects the tag.
        /// </summary>
        /// <param name="tagText">The tag text.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        public virtual TagEditorComponent <T> SelectTag(string tagText)
        {
            if (String.IsNullOrEmpty(tagText))
            {
                throw new ArgumentException($"{nameof(tagText)} cannot be " +
                                            $"null or empty.");
            }

            var selectedTags = SelectedTagElements;

            if (selectedTags.Any())
            {
                var lastActiveEl = selectedTags.Last();
                var width        = lastActiveEl.Size.Width;

                WrappedDriver.CreateActions()
                .MoveToElement(lastActiveEl)
                .MoveByOffset(width, 0)
                .Click()
                .SendKeys(tagText + Keys.Enter)
                .Perform();
            }
            else
            {
                WrappedDriver.CreateActions()
                .MoveToElement(TagEditorContainerElement)
                .Click()
                .SendKeys(tagText + Keys.Enter)
                .Perform();
            }

            return(this);
        }
Beispiel #2
0
        /// <summary>
        /// Closes the active panel.
        /// </summary>
        public virtual void ClosePanel()
        {
            if (!accordianComponentOptions.Collaspable)
            {
                throw new Exception("The " +
                                    "AccordianComponentOptions.Collaspable was set to false.");
            }

            if (HasOpenPanel())
            {
                var waiter = WrappedElement.GetEventWaiter("accordionactivate");

                switch (accordianComponentOptions.Event)
                {
                case "click":
                    ActivePanelElement.Click();
                    break;

                case "mouseover":
                    WrappedDriver.CreateActions()
                    .MoveToElement(ActivePanelElement)
                    .Perform();
                    break;

                default:
                    throw new NotImplementedException(accordianComponentOptions.Event);
                }

                waiter.Wait(accordianComponentOptions.AnimationDuration);
            }
        }
 private void _Write(string content)
 {
     WrappedDriver.CreateActions()
     .MoveToElement(EditableBodyElement)
     .Click()
     .SendKeys(content)
     .Perform();
 }
 private void _HighlightAllText()
 {
     WrappedDriver.CreateActions()
     .MoveToElement(EditableBodyElement)
     .Click()
     .SendKeys(Keys.LeftControl + "a")
     .Perform();
 }
 private void _ClearAllContent()
 {
     WrappedDriver.CreateActions()
     .MoveToElement(EditableBodyElement)
     .Click()
     .SendKeys(Keys.LeftControl + 'a')
     .SendKeys(Keys.Delete)
     .Perform();
 }
        /// <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 #7
0
 private void HideCalendar()
 {
     if (IsPopup && CalendarContainerElement.Displayed)
     {
         WrappedDriver.CreateActions()
         .SendKeys(Keys.Escape)
         .Perform();
         WrappedDriver.Wait(datePickerComponentOptions.AnimationDuration)
         .Until(d => !CalendarContainerElement.Displayed);
     }
 }
        /// <summary>
        /// Sets the size of the editor.
        /// </summary>
        /// <param name="desiredSize">Size of the desired.</param>
        public virtual void SetEditorSize(Size desiredSize)
        {
            var currentDimensions = TinyMCEContainerElement.Size;
            var diff = Size.Subtract(desiredSize, currentDimensions);

            WrappedDriver.CreateActions()
            .MoveToElement(ResizeHandleElement)
            .ClickAndHold()
            .MoveByOffset(diff.Width, diff.Height)
            .Release()
            .Perform();
        }
Beispiel #9
0
        /// <summary>
        /// Deselects the tag.
        /// </summary>
        /// <param name="tagText">The tag text.</param>
        /// <param name="stringComparison">The string comparison.</param>
        /// <returns></returns>
        public virtual TagEditorComponent <T> DeselectTag(string tagText,
                                                          StringComparison stringComparison = StringComparison.Ordinal)
        {
            if (String.IsNullOrEmpty(tagText))
            {
                throw new ArgumentException($"{nameof(tagText)} cannot be " +
                                            $"null or empty.");
            }

            var tagEl = SelectedTagElements.FirstOrDefault(
                e => String.Equals(
                    e.TextHelper().InnerText,
                    tagText,
                    stringComparison));

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

            if (tagEditorConfiguration.UseKeyboardInsteadOfMouseWhenInteracting)
            {
                WrappedDriver.CreateActions()
                .MoveToElement(tagEl)
                .Click()
                .SendKeys(Keys.LeftControl + "a")
                .SendKeys(Keys.Delete)
                .SendKeys(Keys.Enter)
                .SendKeys(Keys.Escape)
                .Perform();
            }
            else
            {
                tagEl
                .GetParentElement()
                .FindElement(By.CssSelector(".tag-editor-delete"))
                .Click();
            }

            WrappedDriver
            .Wait(TimeSpan.FromSeconds(1))
            .Until(d => tagEl.IsStale());

            return(this);
        }
Beispiel #10
0
        /// <summary>
        /// Sets the panel to open and returns the panel content element.
        /// </summary>
        /// <param name="panelName">Name of the panel.</param>
        /// <param name="stringComparison">The string comparison.</param>
        /// <returns></returns>
        public virtual IWebElement SelectPanel(string panelName,
                                               StringComparison stringComparison = StringComparison.Ordinal)
        {
            var isOpen = String.Equals(
                GetActivePanelName(),
                panelName,
                stringComparison);

            if (!isOpen)
            {
                var matchingPanelElement = PanelElements.FirstOrDefault(
                    e => String.Equals(
                        e.TextHelper().InnerText,
                        panelName,
                        stringComparison));

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

                var waiter = WrappedElement.GetEventWaiter("accordionactivate");

                switch (accordianComponentOptions.Event)
                {
                case "click":
                    matchingPanelElement.Click();
                    break;

                case "mouseover":
                    WrappedDriver.CreateActions()
                    .MoveToElement(matchingPanelElement)
                    .Perform();
                    break;

                default:
                    throw new NotImplementedException(accordianComponentOptions.Event);
                }

                waiter.Wait(accordianComponentOptions.AnimationDuration);
            }

            return(ActiveContentElement);
        }