Package ai.test.sdk
Class TestAiDriver
java.lang.Object
ai.test.sdk.TestAiDriver
A convenient wrapper around
RemoteWebDriver which calls out to Test.ai to improve the accuracy of identified elements.- Author:
- Alexander Wu ([email protected])
-
Constructor Summary
ConstructorsConstructorDescriptionTestAiDriver(RemoteWebDriver driver, String apiKey) Constructor, creates a new TestAiDriver with the default server url (sdk.test.ai), non-interactive mode, and with training enabled.TestAiDriver(RemoteWebDriver driver, String apiKey, String serverURL, String testCaseName, boolean train) Constructor, creates a new TestAiDriver. -
Method Summary
Modifier and TypeMethodDescriptionfindByElementName(String elementName) Finds an element byelementName.findElementByClassName(String using) Attempts to find an element by class name.findElementByClassName(String using, String elementName) Attempts to find an element by class name.findElementByCssSelector(String using) Attempts to find an element by css selector.findElementByCssSelector(String using, String elementName) Attempts to find an element by css selector.findElementById(String using) Attempts to find an element by id.findElementById(String using, String elementName) Attempts to find an element by id.findElementByLinkText(String using) Attempts to find an element by link text.findElementByLinkText(String using, String elementName) Attempts to find an element by link text.findElementByName(String using) Attempts to find an element by name.findElementByName(String using, String elementName) Attempts to find an element by name.Attempts to find an element by partial link text.findElementByPartialLinkText(String using, String elementName) Attempts to find an element by partial link text.findElementByTagName(String using) Attempts to find an element by tag name.findElementByTagName(String using, String elementName) Attempts to find an element by tag name.findElementByXPath(String using) Attempts to find an element by xpath.findElementByXPath(String using, String elementName) Attempts to find an element by xpath.findElementsByClassName(String using) Attempts to find all elements with the matching class name.findElementsByCssSelector(String using) Attempts to find all elements with the matching css selector.findElementsById(String using) Attempts to find all elements with the matching id.findElementsByLinkText(String using) Attempts to find all elements with the matching link text.findElementsByName(String using) Attempts to find all elements with the matching name.Attempts to find all elements with the matching partial link text.findElementsByTagName(String using) Attempts to find all elements with the matching tag name.findElementsByXPath(String using) Attempts to find all elements with the matching xpath.voidOpens a web browser and directs it tourl.implicitlyWait(long waitTime) Convenience method, implicitly wait for the specified amount of time.
-
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 wrapapiKey- Your API key, acquired from sdk.test.ai.serverURL- The server URL. Setnullto use the default of sdk.test.ai.testCaseName- The test case name to use for interactive mode. Setting this to something other thannullenables interactive mode.train- Set `true` to enable training for each encountered element.- Throws:
IOException- If there was an initialization error.
-
TestAiDriver
Constructor, creates a new TestAiDriver with the default server url (sdk.test.ai), non-interactive mode, and with training enabled.- Parameters:
driver- TheRemoteWebDriverto wrapapiKey- Your API key, acquired from sdk.test.ai.- Throws:
IOException- If there was an initialization error.
-
-
Method Details
-
implicitlyWait
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
Opens a web browser and directs it tourl.- Parameters:
url- The URL to launch the browser to.
-
findElementByClassName
Attempts to find an element by class name.- Parameters:
using- The class name of the element to findelementName- The label name of the element to be classified. Optional, setnullto auto generate an element name.- Returns:
- The element that was found. Raises an exception otherwise.
-
findElementByClassName
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
Attempts to find all elements with the matching class name.- Parameters:
using- The class name of the elements to find.- Returns:
- A
Listwith any elements that were found, or an emptyListif no matches were found.
-
findElementByCssSelector
Attempts to find an element by css selector.- Parameters:
using- The css selector of the element to findelementName- The label name of the element to be classified. Optional, setnullto auto generate an element name.- Returns:
- The element that was found. Raises an exception otherwise.
-
findElementByCssSelector
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
Attempts to find all elements with the matching css selector.- Parameters:
using- The css selector of the elements to find.- Returns:
- A
Listwith any elements that were found, or an emptyListif no matches were found.
-
findElementById
Attempts to find an element by id.- Parameters:
using- The id of the element to findelementName- The label name of the element to be classified. Optional, setnullto auto generate an element name.- Returns:
- The element that was found. Raises an exception otherwise.
-
findElementById
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
Attempts to find all elements with the matching id.- Parameters:
using- The id of the elements to find.- Returns:
- A
Listwith any elements that were found, or an emptyListif no matches were found.
-
findElementByLinkText
Attempts to find an element by link text.- Parameters:
using- The link text of the element to findelementName- The label name of the element to be classified. Optional, setnullto auto generate an element name.- Returns:
- The element that was found. Raises an exception otherwise.
-
findElementByLinkText
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
Attempts to find all elements with the matching link text.- Parameters:
using- The link text of the elements to find.- Returns:
- A
Listwith any elements that were found, or an emptyListif no matches were found.
-
findElementByName
Attempts to find an element by name.- Parameters:
using- The name of the element to findelementName- The label name of the element to be classified. Optional, setnullto auto generate an element name.- Returns:
- The element that was found. Raises an exception otherwise.
-
findElementByName
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
Attempts to find all elements with the matching name.- Parameters:
using- The name of the elements to find.- Returns:
- A
Listwith any elements that were found, or an emptyListif no matches were found.
-
findElementByPartialLinkText
Attempts to find an element by partial link text.- Parameters:
using- The partial link text of the element to findelementName- The label name of the element to be classified. Optional, setnullto auto generate an element name.- Returns:
- The element that was found. Raises an exception otherwise.
-
findElementByPartialLinkText
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
Attempts to find all elements with the matching partial link text.- Parameters:
using- The partial link text of the elements to find.- Returns:
- A
Listwith any elements that were found, or an emptyListif no matches were found.
-
findElementByTagName
Attempts to find an element by tag name.- Parameters:
using- The tag name of the element to findelementName- The label name of the element to be classified. Optional, setnullto auto generate an element name.- Returns:
- The element that was found. Raises an exception otherwise.
-
findElementByTagName
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
Attempts to find all elements with the matching tag name.- Parameters:
using- The tag name of the elements to find.- Returns:
- A
Listwith any elements that were found, or an emptyListif no matches were found.
-
findElementByXPath
Attempts to find an element by xpath.- Parameters:
using- The xpath of the element to findelementName- The label name of the element to be classified. Optional, setnullto auto generate an element name.- Returns:
- The element that was found. Raises an exception otherwise.
-
findElementByXPath
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
Attempts to find all elements with the matching xpath.- Parameters:
using- The xpath of the elements to find.- Returns:
- A
Listwith any elements that were found, or an emptyListif no matches were found.
-
findByElementName
Finds an element byelementName.- Parameters:
elementName- The label name of the element to be classified.- Returns:
- An element associated with
elementName. Throws NoSuchElementException otherwise.
-