Package ai.test.sdk

Class TestAiDriver

java.lang.Object
ai.test.sdk.TestAiDriver

public class TestAiDriver extends Object
A convenient wrapper around RemoteWebDriver which calls out to Test.ai to improve the accuracy of identified elements.
Author:
Alexander Wu ([email protected])
  • Constructor Details

    • TestAiDriver

      public TestAiDriver(RemoteWebDriver driver, String apiKey, String serverURL, String testCaseName, boolean train) throws IOException
      Constructor, creates a new TestAiDriver.
      Parameters:
      driver - The selenium driver to wrap
      apiKey - Your API key, acquired from sdk.test.ai.
      serverURL - The server URL. Set null to use the default of sdk.test.ai.
      testCaseName - The test case name to use for interactive mode. Setting this to something other than null enables interactive mode.
      train - Set `true` to enable training for each encountered element.
      Throws:
      IOException - If there was an initialization error.
    • TestAiDriver

      public TestAiDriver(RemoteWebDriver driver, String apiKey) throws IOException
      Constructor, creates a new TestAiDriver with the default server url (sdk.test.ai), non-interactive mode, and with training enabled.
      Parameters:
      driver - The RemoteWebDriver to wrap
      apiKey - Your API key, acquired from sdk.test.ai.
      Throws:
      IOException - If there was an initialization error.
  • Method Details

    • implicitlyWait

      public TestAiDriver implicitlyWait(long waitTime)
      Convenience method, implicitly wait for the specified amount of time.
      Parameters:
      waitTime - The number of seconds to implicitly wait.
      Returns:
      This TestAiDriver, for chaining convenience.
    • get

      public void get(String url)
      Opens a web browser and directs it to url.
      Parameters:
      url - The URL to launch the browser to.
    • findElementByClassName

      public WebElement findElementByClassName(String using, String elementName)
      Attempts to find an element by class name.
      Parameters:
      using - The class name of the element to find
      elementName - The label name of the element to be classified. Optional, set null to auto generate an element name.
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementByClassName

      public WebElement findElementByClassName(String using)
      Attempts to find an element by class name.
      Parameters:
      using - The class name of the element to find
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementsByClassName

      public List<WebElement> findElementsByClassName(String using)
      Attempts to find all elements with the matching class name.
      Parameters:
      using - The class name of the elements to find.
      Returns:
      A List with any elements that were found, or an empty List if no matches were found.
    • findElementByCssSelector

      public WebElement findElementByCssSelector(String using, String elementName)
      Attempts to find an element by css selector.
      Parameters:
      using - The css selector of the element to find
      elementName - The label name of the element to be classified. Optional, set null to auto generate an element name.
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementByCssSelector

      public WebElement findElementByCssSelector(String using)
      Attempts to find an element by css selector.
      Parameters:
      using - The css selector of the element to find
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementsByCssSelector

      public List<WebElement> findElementsByCssSelector(String using)
      Attempts to find all elements with the matching css selector.
      Parameters:
      using - The css selector of the elements to find.
      Returns:
      A List with any elements that were found, or an empty List if no matches were found.
    • findElementById

      public WebElement findElementById(String using, String elementName)
      Attempts to find an element by id.
      Parameters:
      using - The id of the element to find
      elementName - The label name of the element to be classified. Optional, set null to auto generate an element name.
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementById

      public WebElement findElementById(String using)
      Attempts to find an element by id.
      Parameters:
      using - The id of the element to find
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementsById

      public List<WebElement> findElementsById(String using)
      Attempts to find all elements with the matching id.
      Parameters:
      using - The id of the elements to find.
      Returns:
      A List with any elements that were found, or an empty List if no matches were found.
    • findElementByLinkText

      public WebElement findElementByLinkText(String using, String elementName)
      Attempts to find an element by link text.
      Parameters:
      using - The link text of the element to find
      elementName - The label name of the element to be classified. Optional, set null to auto generate an element name.
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementByLinkText

      public WebElement findElementByLinkText(String using)
      Attempts to find an element by link text.
      Parameters:
      using - The link text of the element to find
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementsByLinkText

      public List<WebElement> findElementsByLinkText(String using)
      Attempts to find all elements with the matching link text.
      Parameters:
      using - The link text of the elements to find.
      Returns:
      A List with any elements that were found, or an empty List if no matches were found.
    • findElementByName

      public WebElement findElementByName(String using, String elementName)
      Attempts to find an element by name.
      Parameters:
      using - The name of the element to find
      elementName - The label name of the element to be classified. Optional, set null to auto generate an element name.
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementByName

      public WebElement findElementByName(String using)
      Attempts to find an element by name.
      Parameters:
      using - The name of the element to find
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementsByName

      public List<WebElement> findElementsByName(String using)
      Attempts to find all elements with the matching name.
      Parameters:
      using - The name of the elements to find.
      Returns:
      A List with any elements that were found, or an empty List if no matches were found.
    • findElementByPartialLinkText

      public WebElement findElementByPartialLinkText(String using, String elementName)
      Attempts to find an element by partial link text.
      Parameters:
      using - The partial link text of the element to find
      elementName - The label name of the element to be classified. Optional, set null to auto generate an element name.
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementByPartialLinkText

      public WebElement findElementByPartialLinkText(String using)
      Attempts to find an element by partial link text.
      Parameters:
      using - The partial link text of the element to find
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementsByPartialLinkText

      public List<WebElement> findElementsByPartialLinkText(String using)
      Attempts to find all elements with the matching partial link text.
      Parameters:
      using - The partial link text of the elements to find.
      Returns:
      A List with any elements that were found, or an empty List if no matches were found.
    • findElementByTagName

      public WebElement findElementByTagName(String using, String elementName)
      Attempts to find an element by tag name.
      Parameters:
      using - The tag name of the element to find
      elementName - The label name of the element to be classified. Optional, set null to auto generate an element name.
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementByTagName

      public WebElement findElementByTagName(String using)
      Attempts to find an element by tag name.
      Parameters:
      using - The tag name of the element to find
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementsByTagName

      public List<WebElement> findElementsByTagName(String using)
      Attempts to find all elements with the matching tag name.
      Parameters:
      using - The tag name of the elements to find.
      Returns:
      A List with any elements that were found, or an empty List if no matches were found.
    • findElementByXPath

      public WebElement findElementByXPath(String using, String elementName)
      Attempts to find an element by xpath.
      Parameters:
      using - The xpath of the element to find
      elementName - The label name of the element to be classified. Optional, set null to auto generate an element name.
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementByXPath

      public WebElement findElementByXPath(String using)
      Attempts to find an element by xpath.
      Parameters:
      using - The xpath of the element to find
      Returns:
      The element that was found. Raises an exception otherwise.
    • findElementsByXPath

      public List<WebElement> findElementsByXPath(String using)
      Attempts to find all elements with the matching xpath.
      Parameters:
      using - The xpath of the elements to find.
      Returns:
      A List with any elements that were found, or an empty List if no matches were found.
    • findByElementName

      public WebElement findByElementName(String elementName)
      Finds an element by elementName.
      Parameters:
      elementName - The label name of the element to be classified.
      Returns:
      An element associated with elementName. Throws NoSuchElementException otherwise.