Interface CapybaraPortingLayer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ByFactory by  
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      List<org.openqa.selenium.WebElement> all​(org.openqa.selenium.By selector)
      Finds all the elements that match the selector.
      void blur​(org.openqa.selenium.WebElement e)
      Sends a blur event to the provided element
      void check​(String locator)
      Checks the specified checkbox.
      void check​(org.openqa.selenium.WebElement e)
      Checks the checkbox.
      void check​(org.openqa.selenium.WebElement e, boolean state)
      Sets the state of the checkbox to the specified value.
      org.openqa.selenium.WebElement choose​(String locator)
      Select radio button by its name, id, or label text.
      void clickButton​(String text)  
      void clickLink​(String locator)  
      void confirmAlert​(int timeout)
      Deprecated.
      Use runThenConfirmAlert(Runnable, int) and provide the runnable that triggers the alert.
      Object executeScript​(String javaScript, Object... args)
      Executes JavaScript.
      void fillIn​(String formFieldName, Object value)  
      org.openqa.selenium.WebElement find​(org.openqa.selenium.By selector)
      Returns the first visible element that matches the selector.
      org.openqa.selenium.WebElement findIfNotVisible​(org.openqa.selenium.By selector)
      Returns the first element that matches the selector even if not visible.
      org.openqa.selenium.WebElement getElement​(org.openqa.selenium.By selector)
      Works like find(org.openqa.selenium.By) but instead of throwing an exception, this method returns null.
      String getPageSource()
      Get all text of the page including markup.
      org.openqa.selenium.WebElement last​(org.openqa.selenium.By selector)
      Picks up the last visible element that matches given selector.
      org.openqa.selenium.WebElement lastIfNotVisible​(org.openqa.selenium.By selector)
      Picks up the last visible element that matches given selector.
      void runThenConfirmAlert​(Runnable runnable, int timeout)
      Do something that triggers an alert then giving it some time to appear
      Wait<CapybaraPortingLayer> waitFor()  
      org.openqa.selenium.WebElement waitFor​(org.openqa.selenium.By selector)
      Wait until the element that matches the given selector appears.
      org.openqa.selenium.WebElement waitFor​(org.openqa.selenium.By selector, int timeoutSec)
      Wait until the element that matches the given selector appears.
      <MatcherT,​SubjectT extends MatcherT>
      void
      waitFor​(SubjectT item, org.hamcrest.Matcher<MatcherT> matcher, int timeoutSec)
      Wait until a matcher matches.
      <T> Wait<T> waitFor​(T subject)  
      <T> T waitForCond​(Callable<T> block)
      Deprecated.
      <T> T waitForCond​(Callable<T> block, int timeoutSec)
      Deprecated.
    • Method Detail

      • clickButton

        void clickButton​(String text)
      • choose

        org.openqa.selenium.WebElement choose​(String locator)
        Select radio button by its name, id, or label text.
      • waitFor

        <T> Wait<T> waitFor​(T subject)
      • waitFor

        org.openqa.selenium.WebElement waitFor​(org.openqa.selenium.By selector,
                                               int timeoutSec)
        Wait until the element that matches the given selector appears.
      • waitFor

        org.openqa.selenium.WebElement waitFor​(org.openqa.selenium.By selector)
        Wait until the element that matches the given selector appears.
      • waitForCond

        @Deprecated
        <T> T waitForCond​(Callable<T> block,
                          int timeoutSec)
        Deprecated.
        Repeated evaluate the given predicate until it returns true.

        If it times out, an exception will be thrown.

        Parameters:
        timeoutSec - 0 if left to the default value
      • waitFor

        <MatcherT,​SubjectT extends MatcherT> void waitFor​(SubjectT item,
                                                                org.hamcrest.Matcher<MatcherT> matcher,
                                                                int timeoutSec)
        Wait until a matcher matches.
      • find

        org.openqa.selenium.WebElement find​(org.openqa.selenium.By selector)
        Returns the first visible element that matches the selector.
        Throws:
        org.openqa.selenium.NoSuchElementException - if the element is not found.
        See Also:
        if you don't want to see an exception
      • findIfNotVisible

        org.openqa.selenium.WebElement findIfNotVisible​(org.openqa.selenium.By selector)
        Returns the first element that matches the selector even if not visible.
        Throws:
        org.openqa.selenium.NoSuchElementException - if the element is not found.
        See Also:
        if you don't want to see an exception
      • getElement

        org.openqa.selenium.WebElement getElement​(org.openqa.selenium.By selector)
        Works like find(org.openqa.selenium.By) but instead of throwing an exception, this method returns null.
      • fillIn

        void fillIn​(String formFieldName,
                    Object value)
      • check

        void check​(org.openqa.selenium.WebElement e)
        Checks the checkbox.
      • check

        void check​(org.openqa.selenium.WebElement e,
                   boolean state)
        Sets the state of the checkbox to the specified value.
      • blur

        void blur​(org.openqa.selenium.WebElement e)
        Sends a blur event to the provided element
      • all

        List<org.openqa.selenium.WebElement> all​(org.openqa.selenium.By selector)
        Finds all the elements that match the selector.

        Note that this method inherits the same restriction of the WebDriver.findElements(org.openqa.selenium.By), in that its execution is not synchronized with the JavaScript execution of the browser.

        For example, if you click something that's expected to populate additional DOM elements, and then call all() to find them, then all() can execute before those additional DOM elements are populated, thereby failing to find the elements you are looking for.

        In contrast, find(org.openqa.selenium.By) do not have this problem, because it waits until the element that matches the criteria appears.

        So if you are using this method, think carefully. Perhaps you can use find(org.openqa.selenium.By) to achieve what you are looking for (by making the query more specific), or perhaps you can combine this with waitForCond(java.util.concurrent.Callable) so that if you don't find the elements you are looking for in the list, you'll retry.

      • last

        org.openqa.selenium.WebElement last​(org.openqa.selenium.By selector)
        Picks up the last visible element that matches given selector.
      • lastIfNotVisible

        org.openqa.selenium.WebElement lastIfNotVisible​(org.openqa.selenium.By selector)
        Picks up the last visible element that matches given selector.
      • executeScript

        Object executeScript​(String javaScript,
                             Object... args)
        Executes JavaScript.
      • clickLink

        void clickLink​(String locator)
        Parameters:
        locator - Text, ID, or link.
      • check

        void check​(String locator)
        Checks the specified checkbox.
      • confirmAlert

        @Deprecated
        void confirmAlert​(int timeout)
        Deprecated.
        Use runThenConfirmAlert(Runnable, int) and provide the runnable that triggers the alert.
        Confirms an alert giving it some time to appear
        Parameters:
        timeout - Maximum time to wait for the alert to appear, in seconds
      • runThenConfirmAlert

        void runThenConfirmAlert​(Runnable runnable,
                                 int timeout)
        Do something that triggers an alert then giving it some time to appear
        Parameters:
        runnable - Something that will trigger the alert
        timeout - Maximum time to wait for the alert to appear, in seconds
      • getPageSource

        String getPageSource()
        Get all text of the page including markup.