Package ai.test.sdk
Class TestAiDriver
java.lang.Object
org.openqa.selenium.remote.RemoteWebDriver
ai.test.sdk.TestAiDriver
- All Implemented Interfaces:
HasCapabilities,HasInputDevices,Interactive,FindsByClassName,FindsByCssSelector,FindsById,FindsByLinkText,FindsByName,FindsByTagName,FindsByXPath,JavascriptExecutor,SearchContext,TakesScreenshot,WebDriver
A convenient wrapper around
RemoteWebDriver which calls out to Test.ai to improve the accuracy of identified elements.- Author:
- Alexander Wu ([email protected])
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openqa.selenium.remote.RemoteWebDriver
RemoteWebDriver.WhenNested classes/interfaces inherited from interface org.openqa.selenium.WebDriver
WebDriver.ImeHandler, WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts, WebDriver.Window -
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 TypeMethodDescriptionexecuteAsyncScript(String script, Object... args) executeScript(String script, Object... args) findByElementName(String elementName) Finds an element byelementName.findElement(By locator) 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.findElements(By locator) 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.getMouse()<X> XgetScreenshotAs(OutputType<X> outputType) getTitle()implicitlyWait(long waitTime) Convenience method, implicitly wait for the specified amount of time.manage()navigate()voidperform(Collection<Sequence> actions) voidquit()voidvoidsetErrorHandler(ErrorHandler handler) voidsetFileDetector(FileDetector detector) voidsetLogLevel(Level level) switchTo()toString()Methods inherited from class org.openqa.selenium.remote.RemoteWebDriver
builder, close
-
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.
-
executeAsyncScript
- Specified by:
executeAsyncScriptin interfaceJavascriptExecutor- Overrides:
executeAsyncScriptin classRemoteWebDriver
-
executeScript
- Specified by:
executeScriptin interfaceJavascriptExecutor- Overrides:
executeScriptin classRemoteWebDriver
-
get
Opens a web browser and directs it tourl.- Specified by:
getin interfaceWebDriver- Overrides:
getin classRemoteWebDriver- Parameters:
url- The URL to launch the browser to.
-
findElement
- Specified by:
findElementin interfaceSearchContext- Specified by:
findElementin interfaceWebDriver- Overrides:
findElementin classRemoteWebDriver
-
findElements
- Specified by:
findElementsin interfaceSearchContext- Specified by:
findElementsin interfaceWebDriver- Overrides:
findElementsin classRemoteWebDriver
-
getCapabilities
- Specified by:
getCapabilitiesin interfaceHasCapabilities- Overrides:
getCapabilitiesin classRemoteWebDriver
-
getCommandExecutor
- Overrides:
getCommandExecutorin classRemoteWebDriver
-
getCurrentUrl
- Specified by:
getCurrentUrlin interfaceWebDriver- Overrides:
getCurrentUrlin classRemoteWebDriver
-
getErrorHandler
- Overrides:
getErrorHandlerin classRemoteWebDriver
-
getFileDetector
- Overrides:
getFileDetectorin classRemoteWebDriver
-
getKeyboard
- Specified by:
getKeyboardin interfaceHasInputDevices- Overrides:
getKeyboardin classRemoteWebDriver
-
getMouse
- Specified by:
getMousein interfaceHasInputDevices- Overrides:
getMousein classRemoteWebDriver
-
getPageSource
- Specified by:
getPageSourcein interfaceWebDriver- Overrides:
getPageSourcein classRemoteWebDriver
-
getScreenshotAs
- Specified by:
getScreenshotAsin interfaceTakesScreenshot- Overrides:
getScreenshotAsin classRemoteWebDriver
-
getSessionId
- Overrides:
getSessionIdin classRemoteWebDriver
-
getTitle
- Specified by:
getTitlein interfaceWebDriver- Overrides:
getTitlein classRemoteWebDriver
-
getWindowHandle
- Specified by:
getWindowHandlein interfaceWebDriver- Overrides:
getWindowHandlein classRemoteWebDriver
-
getWindowHandles
- Specified by:
getWindowHandlesin interfaceWebDriver- Overrides:
getWindowHandlesin classRemoteWebDriver
-
manage
- Specified by:
managein interfaceWebDriver- Overrides:
managein classRemoteWebDriver
-
perform
- Specified by:
performin interfaceInteractive- Overrides:
performin classRemoteWebDriver
-
quit
public void quit()- Specified by:
quitin interfaceWebDriver- Overrides:
quitin classRemoteWebDriver
-
resetInputState
public void resetInputState()- Specified by:
resetInputStatein interfaceInteractive- Overrides:
resetInputStatein classRemoteWebDriver
-
setErrorHandler
- Overrides:
setErrorHandlerin classRemoteWebDriver
-
setFileDetector
- Overrides:
setFileDetectorin classRemoteWebDriver
-
setLogLevel
- Overrides:
setLogLevelin classRemoteWebDriver
-
switchTo
- Specified by:
switchToin interfaceWebDriver- Overrides:
switchToin classRemoteWebDriver
-
toString
- Overrides:
toStringin classRemoteWebDriver
-
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.- Specified by:
findElementByClassNamein interfaceFindsByClassName- Overrides:
findElementByClassNamein classRemoteWebDriver- 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.- Specified by:
findElementsByClassNamein interfaceFindsByClassName- Overrides:
findElementsByClassNamein classRemoteWebDriver- 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.- Specified by:
findElementByCssSelectorin interfaceFindsByCssSelector- Overrides:
findElementByCssSelectorin classRemoteWebDriver- 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.- Specified by:
findElementsByCssSelectorin interfaceFindsByCssSelector- Overrides:
findElementsByCssSelectorin classRemoteWebDriver- 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.- Specified by:
findElementByIdin interfaceFindsById- Overrides:
findElementByIdin classRemoteWebDriver- 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.- Specified by:
findElementsByIdin interfaceFindsById- Overrides:
findElementsByIdin classRemoteWebDriver- 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.- Specified by:
findElementByLinkTextin interfaceFindsByLinkText- Overrides:
findElementByLinkTextin classRemoteWebDriver- 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.- Specified by:
findElementsByLinkTextin interfaceFindsByLinkText- Overrides:
findElementsByLinkTextin classRemoteWebDriver- 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.- Specified by:
findElementByNamein interfaceFindsByName- Overrides:
findElementByNamein classRemoteWebDriver- 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.- Specified by:
findElementsByNamein interfaceFindsByName- Overrides:
findElementsByNamein classRemoteWebDriver- 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.- Specified by:
findElementByPartialLinkTextin interfaceFindsByLinkText- Overrides:
findElementByPartialLinkTextin classRemoteWebDriver- 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.- Specified by:
findElementsByPartialLinkTextin interfaceFindsByLinkText- Overrides:
findElementsByPartialLinkTextin classRemoteWebDriver- 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.- Specified by:
findElementByTagNamein interfaceFindsByTagName- Overrides:
findElementByTagNamein classRemoteWebDriver- 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.- Specified by:
findElementsByTagNamein interfaceFindsByTagName- Overrides:
findElementsByTagNamein classRemoteWebDriver- 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.- Specified by:
findElementByXPathin interfaceFindsByXPath- Overrides:
findElementByXPathin classRemoteWebDriver- 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.- Specified by:
findElementsByXPathin interfaceFindsByXPath- Overrides:
findElementsByXPathin classRemoteWebDriver- 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.
-