Class FluentDriver

    • Constructor Detail

      • FluentDriver

        public FluentDriver​(org.openqa.selenium.WebDriver driver,
                            Configuration configuration,
                            FluentControl adapter)
        Wrap the driver into a Fluent driver.
        Parameters:
        driver - underlying selenium driver
        configuration - configuration
        adapter - adapter fluent control interface
    • Method Detail

      • 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.
      • 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.
        Parameters:
        fileName - file name for html dump
      • canTakeScreenShot

        public boolean canTakeScreenShot()
        Description copied from interface: SnapshotControl
        Check if underlying WebDriver can take screenshot.
        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.
      • 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.
        Parameters:
        fileName - file name for screenshot
      • getDriver

        public org.openqa.selenium.WebDriver getDriver()
        Description copied from interface: SeleniumDriverControl
        Get the actual underlying Selenium WebDriver.

        To customize the WebDriver, you should configure FluentControl.getWebDriver() or override IFluentAdapter.newWebDriver().

        This method can't be overridden to customize the WebDriver.

        Returns:
        The actual underlying Selenium WebDriver
      • getAppiumDriver

        public io.appium.java_client.AppiumDriver getAppiumDriver()
        Description copied from interface: SeleniumDriverControl
        Get the actual underlying AppiumDriver.

        To customize the WebDriver, you should configure FluentControl.getWebDriver() or override IFluentAdapter.newWebDriver().

        This method can't be overridden to customize the AppiumDriver.

        Returns:
        The actual underlying AppiumDriver
      • events

        public EventsRegistry events()
        Description copied from interface: EventsControl
        Retrieves an event registry to register event listeners.
        Returns:
        the event registry.
      • mouse

        public MouseActions mouse()
        Description copied from interface: InputControl
        Execute mouse actions
        Returns:
        mouse actions object
      • keyboard

        public KeyboardActions keyboard()
        Description copied from interface: InputControl
        Execute keyboard actions
        Returns:
        mouse keyboard object
      • window

        public WindowAction window()
        Description copied from interface: NavigationControl
        Exposes methods on browser window
        Returns:
        Window actions
      • await

        public FluentWait await()
        Description copied from interface: AwaitControl
        wait for an asynchronous call
        Returns:
        FluentWait element
      • getCookies

        public Set<org.openqa.selenium.Cookie> getCookies()
        Description copied from interface: NavigationControl
        return the cookies as a set
        Returns:
        set of cookies
      • getCookie

        public org.openqa.selenium.Cookie getCookie​(String name)
        Description copied from interface: NavigationControl
        return the corresponding cookie given a name
        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.
        Returns:
        current URL
      • pageSource

        public String pageSource()
        Description copied from interface: NavigationControl
        Return the source of the page
        Returns:
        source of the page under test
      • goTo

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

        public void goTo​(String url)
        Description copied from interface: NavigationControl
        Open the url page
        Parameters:
        url - page URL to visit
      • goToInNewTab

        public void goToInNewTab​(String url)
        Description copied from interface: NavigationControl
        Open the url page in a new tab
        Parameters:
        url - the url of the page
      • capabilities

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

        public FluentJavascript executeScript​(String script,
                                              Object... args)
        Description copied from interface: JavascriptControl
        Execute a script, synchronously.
        Parameters:
        script - script source to execute
        args - script arguments
        Returns:
        an object wrapping the result
      • executeAsyncScript

        public FluentJavascript executeAsyncScript​(String script,
                                                   Object... args)
        Description copied from interface: JavascriptControl
        Execute a script, asynchronously.
        Parameters:
        script - script source to execute
        args - script arguments
        Returns:
        an object wrapping the result
      • 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)
        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)
        Parameters:
        element - fluent web element to switch to
      • switchTo

        public void switchTo()
        Description copied from interface: NavigationControl
        Switch to the default element
      • switchToDefault

        public void switchToDefault()
        Description copied from interface: NavigationControl
        Switch to the default element
      • alert

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

        public void quit()
        Quit the underlying web driver and release fluent driver resources.
      • releaseFluent

        public void releaseFluent()
        Release fluent driver resources.
      • getSearch

        protected Search getSearch()
        Return the Search required for this class.
        Returns:
        the Search object
      • inject

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

        public <T> T newInstance​(Class<T> cls)
        Description copied from interface: FluentInjectControl
        Creates a new instance of a class inject it.
        Type Parameters:
        T - type of the object
        Parameters:
        cls - class of the object to create
        Returns:
        new container instance
        See Also:
        FluentInjectControl.inject(Object)
      • injectComponent

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

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

        public ChromiumApi getChromiumApi()
        Description copied from interface: ChromiumControl
        Features related to browser control under devtools protocol.
        Returns:
        a new chromium api instance
      • find

        public FluentList<FluentWebElement> find​(String selector,
                                                 SearchFilter... filters)
        Description copied from interface: SearchControl
        Find list of elements with CSS selector and filters.
        Parameters:
        selector - CSS selector
        filters - set of filters
        Returns:
        list of element
      • find

        public FluentList<FluentWebElement> find​(org.openqa.selenium.By locator,
                                                 SearchFilter... filters)
        Description copied from interface: SearchControl
        Find list of elements with Selenium locator and filters.
        Parameters:
        locator - elements locator
        filters - filters set
        Returns:
        list of elements
      • find

        public FluentList<FluentWebElement> find​(List<org.openqa.selenium.WebElement> rawElements)
        Description copied from interface: SearchControl
        Wrap raw selenium elements into a list of elements.
        Parameters:
        rawElements - raw selenium elements
        Returns:
        list of element
      • $

        public FluentList<FluentWebElement> $​(List<org.openqa.selenium.WebElement> rawElements)
        Description copied from interface: SearchControl
        Wrap raw selenium elements into a list of elements.
        Parameters:
        rawElements - raw selenium elements
        Returns:
        list of element
      • el

        public FluentWebElement el​(org.openqa.selenium.WebElement rawElement)
        Description copied from interface: SearchControl
        Wrap existing raw selenium element into an element.
        Parameters:
        rawElement - raw selenium element
        Returns:
        element
      • 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.
        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 <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.
        Type Parameters:
        T - type of the component
        Parameters:
        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.
        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
      • 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.
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        elements - list of elements
        Returns:
        new list of fluent web element
      • isComponentClass

        public boolean isComponentClass​(Class<?> componentClass)
        Description copied from interface: ComponentInstantiator
        Check if this class is a component class.
        Parameters:
        componentClass - class to check
        Returns:
        true if this class is a component class, false otherwise
      • 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.
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        elements - elements
        Returns:
        new list of components
      • 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.
        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)
        Description copied from interface: ComponentInstantiator
        Create and register an empty fluent list of the provided type.
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        Returns:
        new list of fluent web element
      • newFluent

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

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

        public FluentList<FluentWebElement> asFluentList​(org.openqa.selenium.WebElement... elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list from the argument WebElements.
        Parameters:
        elements - list of elements
        Returns:
        new list of fluent web element
      • asFluentList

        public FluentList<FluentWebElement> asFluentList​(Iterable<org.openqa.selenium.WebElement> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list from the argument collection of WebElements.
        Parameters:
        elements - list of elements
        Returns:
        new list of fluent web element
      • 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.
        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.
        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
      • asFluentList

        public FluentList<FluentWebElement> asFluentList​(List<org.openqa.selenium.WebElement> elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list from the argument list of WebElements.
        Parameters:
        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.
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        elements - list of elements
        Returns:
        new list of fluent web element
      • 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.
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        elements - elements
        Returns:
        new list of components
      • 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.
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        element - wrapped element
        Returns:
        new instance of the component
      • 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.
        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.
        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,
                                                              List<T> componentsList)
        Description copied from interface: ComponentInstantiator
        Create and register a new list of component from the given component list.
        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 <T> ComponentList<T> newComponentList​(Class<T> componentClass)
        Description copied from interface: ComponentInstantiator
        Create and register an empty list of component.
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - type of the component
        Returns:
        new list of components
      • 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.
        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,
                                                                        T... elements)
        Description copied from interface: ComponentInstantiator
        Create and register a new fluent list.
        Type Parameters:
        T - type of the component
        Parameters:
        componentClass - class of the component
        elements - list of elements
        Returns:
        new list of fluent web element
      • 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.
        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