Class FluentWebElement

    • Constructor Detail

      • FluentWebElement

        public FluentWebElement​(org.openqa.selenium.WebElement element,
                                FluentControl control,
                                ComponentInstantiator instantiator)
        Creates a new fluent web element.
        Parameters:
        element - underlying element
        control - control interface
        instantiator - component instantiator
    • Method Detail

      • unshadowAllFields

        public void unshadowAllFields()
      • alert

        public Alert alert()
        Description copied from interface: AlertControl
        Get an object to control the alert window.
        Specified by:
        alert in interface AlertControl
        Returns:
        an alert object
      • takeHtmlDump

        public void takeHtmlDump()
        Description copied from interface: SnapshotControl
        Take a html dump of the browser DOM. By default the file will be a html named by the current timestamp.
        Specified by:
        takeHtmlDump in interface SnapshotControl
      • takeHtmlDump

        public void takeHtmlDump​(String fileName)
        Description copied from interface: SnapshotControl
        Take a html dump of the browser DOM into a file given by the fileName param.
        Specified by:
        takeHtmlDump in interface SnapshotControl
        Parameters:
        fileName - file name for html dump
      • canTakeScreenShot

        public boolean canTakeScreenShot()
        Description copied from interface: SnapshotControl
        Check if underlying WebDriver can take screenshot.
        Specified by:
        canTakeScreenShot in interface SnapshotControl
        Returns:
        true if screenshot can be taken, false otherwise
      • takeScreenshot

        public void takeScreenshot()
        Description copied from interface: SnapshotControl
        Take a snapshot of the browser. By default the file will be a png named by the current timestamp.
        Specified by:
        takeScreenshot in interface SnapshotControl
      • takeScreenshot

        public void takeScreenshot​(String fileName)
        Description copied from interface: SnapshotControl
        Take a snapshot of the browser into a file given by the fileName param.
        Specified by:
        takeScreenshot in interface SnapshotControl
        Parameters:
        fileName - file name for screenshot
      • goTo

        public <P extends FluentPage> P goTo​(P page)
        Description copied from interface: NavigationControl
        Open the page, using the url defined in the page
        Specified by:
        goTo in interface NavigationControl
        Type Parameters:
        P - Type of FluentPage
        Parameters:
        page - page to open
        Returns:
        Opened page.
        See Also:
        FluentPage.getUrl()
      • switchTo

        public void switchTo​(FluentList<? extends FluentWebElement> elements)
        Description copied from interface: NavigationControl
        Switch to the first selected Element (if element is null or not an iframe, or doesn't have an id then switch to the default)
        Specified by:
        switchTo in interface NavigationControl
        Parameters:
        elements - fluent list of fluent web elements
      • switchTo

        public void switchTo​(FluentWebElement element)
        Description copied from interface: NavigationControl
        Switch to the selected Element (if element is null or not an iframe, or doesn't have an id then switch to the default)
        Specified by:
        switchTo in interface NavigationControl
        Parameters:
        element - fluent web element to switch to
      • getCookie

        public org.openqa.selenium.Cookie getCookie​(String name)
        Description copied from interface: NavigationControl
        return the corresponding cookie given a name
        Specified by:
        getCookie in interface NavigationControl
        Parameters:
        name - cookie name
        Returns:
        cookie selected by name
      • url

        public String url()
        Description copied from interface: NavigationControl
        Return the url of the page. If a base url is provided, the current url will be relative to that base url.
        Specified by:
        url in interface NavigationControl
        Returns:
        current URL
      • css

        public CssSupport css()
        Description copied from interface: CssControl
        Features related to CSS loaded in the active page.
        Specified by:
        css in interface CssControl
        Returns:
        a CssSupport instance
      • inject

        public ContainerContext inject​(Object container)
        Description copied from interface: FluentInjectControl
        Inject object with FluentLenium resources.
        Specified by:
        inject in interface FluentInjectControl
        Parameters:
        container - container to inject with FluentLenium resources
        Returns:
        The container context related to the injected container
      • injectComponent

        public ContainerContext injectComponent​(Object componentContainer,
                                                Object parentContainer,
                                                org.openqa.selenium.SearchContext context)
        Description copied from interface: FluentInjectControl
        Inject object with FluentLenium resources, using given search context and parent container.
        Specified by:
        injectComponent in interface FluentInjectControl
        Parameters:
        componentContainer - container to inject with FluentLenium resources
        parentContainer - parent container
        context - search context to use for injection
        Returns:
        The container context related to the injected container
      • newFluent

        public FluentWebElement newFluent​(org.openqa.selenium.WebElement element)
        Description copied from interface: ComponentInstantiator
        Create and register a new FluentWebElement from the given WebElement.
        Specified by:
        newFluent in interface ComponentInstantiator
        Parameters:
        element - wrapped element
        Returns:
        new instance of the component
      • newComponent

        public <T> T newComponent​(Class<T> componentClass,
                                  org.openqa.selenium.WebElement element)
        Description copied from interface: ComponentInstantiator
        Create and register a new component of the provided type from the given WebElement.
        Specified by:
        newComponent in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        element - wrapped element
        Returns:
        new instance of the component
      • newFluentList

        public <T extends FluentWebElementFluentList<T> newFluentList​(Class<T> componentClass)
        Description copied from interface: ComponentInstantiator
        Create and register an empty fluent list of the provided type.
        Specified by:
        newFluentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        Returns:
        new list of fluent web element
      • newFluentList

        public <T extends FluentWebElementFluentList<T> newFluentList​(Class<T> componentClass,
                                                                        T... elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list.
        Specified by:
        newFluentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        elements - list of elements
        Returns:
        new list of fluent web element
      • newFluentList

        public <T extends FluentWebElementFluentList<T> newFluentList​(Class<T> componentClass,
                                                                        List<T> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list.
        Specified by:
        newFluentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        elements - list of elements
        Returns:
        new list of fluent web element
      • asFluentList

        public <T extends FluentWebElementFluentList<T> asFluentList​(Class<T> componentClass,
                                                                       org.openqa.selenium.WebElement... elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list.
        Specified by:
        asFluentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        elements - list of elements
        Returns:
        new list of fluent web element
      • asFluentList

        public <T extends FluentWebElementFluentList<T> asFluentList​(Class<T> componentClass,
                                                                       Iterable<org.openqa.selenium.WebElement> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list.
        Specified by:
        asFluentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        elements - list of elements
        Returns:
        new list of fluent web element
      • asFluentList

        public <T extends FluentWebElementFluentList<T> asFluentList​(Class<T> componentClass,
                                                                       List<org.openqa.selenium.WebElement> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list.
        Specified by:
        asFluentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        elements - list of elements
        Returns:
        new list of fluent web element
      • newComponentList

        public <T> ComponentList<T> newComponentList​(Class<T> componentClass)
        Description copied from interface: ComponentInstantiator
        Create and register an empty list of component.
        Specified by:
        newComponentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        Returns:
        new list of components
      • asComponentList

        public <T> ComponentList<T> asComponentList​(Class<T> componentClass,
                                                    org.openqa.selenium.WebElement... elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given element iterable.
        Specified by:
        asComponentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        elements - elements
        Returns:
        new list of components
      • asComponentList

        public <T> ComponentList asComponentList​(Class<T> componentClass,
                                                 Iterable<org.openqa.selenium.WebElement> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given element iterable.
        Specified by:
        asComponentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        elements - elements
        Returns:
        new list of components
      • asComponentList

        public <T> ComponentList<T> asComponentList​(Class<T> componentClass,
                                                    List<org.openqa.selenium.WebElement> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given element iterable.
        Specified by:
        asComponentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        elements - elements
        Returns:
        new list of components
      • newComponentList

        public <T> ComponentList<T> newComponentList​(Class<T> componentClass,
                                                     T... componentsList)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given component list.
        Specified by:
        newComponentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        componentsList - components list
        Returns:
        new list of components
      • newComponentList

        public <T> ComponentList<T> newComponentList​(Class<T> componentClass,
                                                     List<T> componentsList)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given component list.
        Specified by:
        newComponentList in interface ComponentInstantiator
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        componentsList - components list
        Returns:
        new list of components
      • newComponentList

        public <L extends List<T>,​T> L newComponentList​(Class<L> listClass,
                                                              Class<T> componentClass)
        Description copied from interface: ComponentInstantiator
        Create and register an empty list of component.
        Specified by:
        newComponentList in interface ComponentInstantiator
        Type Parameters:
        L - type of the list
        T - type of the component
        Parameters:
        listClass - type of the list
        componentClass - type of the component
        Returns:
        new list of components
      • asComponentList

        public <L extends List<T>,​T> L asComponentList​(Class<L> listClass,
                                                             Class<T> componentClass,
                                                             org.openqa.selenium.WebElement... elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given element iterable.
        Specified by:
        asComponentList in interface ComponentInstantiator
        Type Parameters:
        L - type of the list
        T - type of the component
        Parameters:
        listClass - type of the list
        componentClass - type of the component
        elements - elements
        Returns:
        new list of components
      • asComponentList

        public <L extends List<T>,​T> L asComponentList​(Class<L> listClass,
                                                             Class<T> componentClass,
                                                             Iterable<org.openqa.selenium.WebElement> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given element iterable.
        Specified by:
        asComponentList in interface ComponentInstantiator
        Type Parameters:
        L - type of the list
        T - type of the component
        Parameters:
        listClass - type of the list
        componentClass - type of the component
        elements - elements
        Returns:
        new list of components
      • asComponentList

        public <L extends List<T>,​T> L asComponentList​(Class<L> listClass,
                                                             Class<T> componentClass,
                                                             List<org.openqa.selenium.WebElement> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given element iterable.
        Specified by:
        asComponentList in interface ComponentInstantiator
        Type Parameters:
        L - type of the list
        T - type of the component
        Parameters:
        listClass - type of the list
        componentClass - type of the component
        elements - elements
        Returns:
        new list of components
      • newComponentList

        public <L extends List<T>,​T> L newComponentList​(Class<L> listClass,
                                                              Class<T> componentClass,
                                                              T... componentsList)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given component list.
        Specified by:
        newComponentList in interface ComponentInstantiator
        Type Parameters:
        L - type of the list
        T - type of the component
        Parameters:
        listClass - type of the list
        componentClass - type of the component
        componentsList - components list
        Returns:
        new list of components
      • newComponentList

        public <L extends List<T>,​T> L newComponentList​(Class<L> listClass,
                                                              Class<T> componentClass,
                                                              List<T> componentsList)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given component list.
        Specified by:
        newComponentList in interface ComponentInstantiator
        Type Parameters:
        L - type of the list
        T - type of the component
        Parameters:
        listClass - type of the list
        componentClass - type of the component
        componentsList - components list
        Returns:
        new list of components
      • isComponentClass

        public boolean isComponentClass​(Class<?> componentClass)
        Description copied from interface: ComponentInstantiator
        Check if this class is a component class.
        Specified by:
        isComponentClass in interface ComponentInstantiator
        Parameters:
        componentClass - class to check
        Returns:
        true if this class is a component class, false otherwise
      • isComponentListClass

        public boolean isComponentListClass​(Class<? extends List<?>> componentListClass)
        Description copied from interface: ComponentInstantiator
        Check if this class is a component list class.
        Specified by:
        isComponentListClass in interface ComponentInstantiator
        Parameters:
        componentListClass - class to check
        Returns:
        true if this class is a component list class, false otherwise
      • capabilities

        public org.openqa.selenium.Capabilities capabilities()
        Description copied from interface: CapabilitiesControl
        Get the actual capabilities of the underlying Selenium WebDriver.
        Specified by:
        capabilities in interface CapabilitiesControl
        Returns:
        actual capabilities.
        See Also:
        HasCapabilities.getCapabilities()
      • now

        public FluentWebElement now​(boolean force)
        Description copied from interface: FluentProxyState
        Search for the element now, actually performing the search on the WebDriver.

        It has no effect if the element is already loaded.

        Specified by:
        now in interface FluentProxyState<FluentWebElement>
        Parameters:
        force - force the search even if element is already loaded
        Returns:
        this object reference to chain calls.
      • axes

        @Deprecated
        public Dom axes()
        Deprecated.
        Use dom() instead.
        XPath Axes accessor (parent, ancestors, preceding, following, ...).
        Returns:
        object to perform XPath Axes transformations.
      • dom

        public Dom dom()
        XPath Axes accessor (parent, ancestors, preceding, following, ...).
        Returns:
        object to perform XPath Axes transformations.
      • conditions

        public FluentConditions conditions()
        Get a conditions object used to verify condition on this element.
        Returns:
        conditions object
      • await

        public FluentWaitElement await()
        Build a wait object to wait for a condition of this element.
        Returns:
        a wait object
      • mouse

        public MouseElementActions mouse()
        Execute mouse actions on the element
        Returns:
        mouse actions object
      • keyboard

        public KeyboardElementActions keyboard()
        Execute keyboard actions on the element
        Returns:
        keyboard actions object
      • as

        public <T> T as​(Class<T> componentClass)
        Wrap all underlying elements in a component.
        Type Parameters:
        T - type of component
        Parameters:
        componentClass - component class
        Returns:
        element as component.
      • clear

        public FluentWebElement clear()
        Clear the element
        Returns:
        fluent web element
      • clearReactInput

        public FluentWebElement clearReactInput()
        Clear React input using Backspace only
        Returns:
        fluent web element
      • name

        public String name()
        return the name of the element
        Returns:
        name of the element
      • attribute

        public String attribute​(String name)
        return any value of custom attribute (generated=true will return "true" if attribute("generated") is called.
        Parameters:
        name - custom attribute name
        Returns:
        name value
        See Also:
        WebElement.getAttribute(String)
      • cssValue

        public String cssValue​(String propertyName)
        Get the value of a given CSS property.
        Parameters:
        propertyName - the css property name of the element
        Returns:
        The current, computed value of the property.
        See Also:
        WebElement.getCssValue(String)
      • id

        public String id()
        return the id of the elements
        Returns:
        id of element
      • text

        public String text()
        return the visible text of the element
        Returns:
        text of element
        See Also:
        WebElement.getText()
      • textContent

        public String textContent()
        return the text content of the element (even invisible through textContent attribute)
        Returns:
        text content of element
      • value

        public String value()
        return the value of the elements
        Returns:
        value of attribute
      • displayed

        public boolean displayed()
        return true if the element is displayed, other way return false
        Returns:
        boolean value of displayed check
        See Also:
        WebElement.isDisplayed()
      • enabled

        public boolean enabled()
        return true if the element is enabled, other way return false
        Returns:
        boolean value of enabled check
        See Also:
        WebElement.isEnabled()
      • selected

        public boolean selected()
        return true if the element is selected, other way false
        Returns:
        boolean value of selected check
        See Also:
        WebElement.isSelected()
      • clickable

        public boolean clickable()
        Check that this element is visible and enabled such that you can click it.
        Returns:
        true if the element can be clicked, false otherwise.
      • stale

        public boolean stale()
        Check that this element is no longer attached to the DOM.
        Returns:
        false is the element is still attached to the DOM, true otherwise.
      • tagName

        public String tagName()
        return the tag name
        Returns:
        string value of tag name
        See Also:
        WebElement.getTagName()
      • getElement

        public org.openqa.selenium.WebElement getElement()
        return the webElement
        Returns:
        web element
      • getWrappedElement

        public org.openqa.selenium.WebElement getWrappedElement()
        Specified by:
        getWrappedElement in interface org.openqa.selenium.WrapsElement
      • size

        public org.openqa.selenium.Dimension size()
        return the size of the element
        Returns:
        dimension/size of element
        See Also:
        WebElement.getSize()
      • el

        public FluentWebElement el​(org.openqa.selenium.WebElement rawElement)
        Description copied from interface: SearchControl
        Wrap existing raw selenium element into an element.
        Specified by:
        el in interface SearchControl<FluentWebElement>
        Parameters:
        rawElement - raw selenium element
        Returns:
        element
      • html

        public String html()
        Get the HTML of a the element
        Returns:
        the underlying html content
      • withHook

        public <O,​H extends FluentHook<O>> FluentWebElement withHook​(Class<H> hook,
                                                                           O options)
        Description copied from interface: HookControl
        Enable a hook with given options.
        Specified by:
        withHook in interface HookControl<FluentWebElement>
        Type Parameters:
        O - Type of the hook
        H - Type of the hook options
        Parameters:
        hook - hook class to enable
        options - hook options to apply
        Returns:
        this object reference to chain calls
      • withHook

        public <O,​H extends FluentHook<O>> FluentWebElement withHook​(Class<H> hook)
        Description copied from interface: HookControl
        Enable a hook with default options.
        Specified by:
        withHook in interface HookControl<FluentWebElement>
        Type Parameters:
        O - Type of the hook
        H - Type of the hook options
        Parameters:
        hook - hook class to enable
        Returns:
        this object reference to chain calls
      • noHook

        public <R> R noHook​(Function<FluentWebElement,​R> function)
        Description copied from interface: HookControl
        Invoke a function with no hook.
        Specified by:
        noHook in interface HookControl<FluentWebElement>
        Type Parameters:
        R - return type
        Parameters:
        function - function to invoke
        Returns:
        return value of the given function
      • scrollIntoView

        public FluentWebElement scrollIntoView​(boolean alignWithTop)
        Description copied from interface: FluentJavascriptActions
        Scrolls the current element into the visible area of the browser window.
        Specified by:
        scrollIntoView in interface FluentJavascriptActions
        Parameters:
        alignWithTop - If true, the top of the element will be aligned to the top of the visible area of the scrollable ancestor. If false, the bottom of the element will be aligned to the bottom of the visible area of the scrollable ancestor.
        Returns:
        this object reference to chain methods calls
        See Also:
        element.scrollIntoView
      • withLabelHint

        public FluentWebElement withLabelHint​(String... labelHint)
        Description copied from interface: FluentLabel
        Add a label hint that will be appended to the representation of this object for error message.
        Specified by:
        withLabelHint in interface FluentLabel<FluentWebElement>
        Parameters:
        labelHint - label hints to add
        Returns:
        reference to this object to chain calls
      • withLabel

        public FluentWebElement withLabel​(String label)
        Description copied from interface: FluentLabel
        Apply a label that will be displayed as the representation of this object for error message.
        Specified by:
        withLabel in interface FluentLabel<FluentWebElement>
        Parameters:
        label - label to use
        Returns:
        reference to this object to chain calls