Package ai.devtools.appium
Class SmartDriver<T extends io.appium.java_client.MobileElement>
java.lang.Object
ai.devtools.appium.SmartDriver<T>
The
SmartDriver class is a wrapper around a RemoteWebDriver that uses the results of the dev-tools.ai classifier for improved robustness, finding elements visually and avoiding broken selectors.-
Field Summary
FieldsModifier and TypeFieldDescriptionio.appium.java_client.AppiumDriver<T>The driver used by the user that we're wrapping.booleanbooleandoubleThe screen density multiplier -
Constructor Summary
ConstructorsConstructorDescriptionSmartDriver(io.appium.java_client.AppiumDriver<T> driver, String apiKey) Constructor, creates a new SmartDriver with the default server url (smartdriver.dev-tools.ai), non-interactive mode, and with training enabled.SmartDriver(io.appium.java_client.AppiumDriver<T> driver, String apiKey, Map<String, Object> initializationDict) Constructor, creates a new SmartDriver. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()executeAsyncScript(String script, Object... args) executeScript(String script, Object... args) Finds an elements byelementName.findByElementName(String elementName) Finds an element byelementName.io.appium.java_client.MobileElementfindElement(By locator) findElement(By locator, String elementName) 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.findElementByElementName(String elementName) Finds an element byelementName.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.voidgetMouse()<X> XgetScreenshotAs(OutputType<X> outputType) getTitle()implicitlyWait(long waitTime) Convenience method, implicitly wait for the specified amount of time.booleanlocation()manage()navigate()voidperform(Collection<Sequence> actions) voidquit()voidvoidrotate(DeviceRotation rotation) voidrotate(ScreenOrientation orientation) rotation()voidscrollPage(int amount) voidscrollToElement(T element, Boolean scrollUp) voidsetErrorHandler(ErrorHandler handler) voidsetFileDetector(FileDetector detector) voidsetLocation(Location location) voidsetLogLevel(Level level) switchTo()toString()
-
Field Details
-
isIOS
public boolean isIOS -
isEspresso
public boolean isEspresso -
driver
The driver used by the user that we're wrapping. -
multiplier
public double multiplierThe screen density multiplier
-
-
Constructor Details
-
SmartDriver
public SmartDriver(io.appium.java_client.AppiumDriver<T> driver, String apiKey, Map<String, Object> initializationDict) throws IOExceptionConstructor, creates a new SmartDriver.- Parameters:
driver- TheRemoteWebDriverto wrapapiKey- Your API key, acquired from smartdriver.dev-tools.ai.initializationDict- The configuration options for the driver.- Throws:
IOException- If there was an initialization error.
-
SmartDriver
Constructor, creates a new SmartDriver with the default server url (smartdriver.dev-tools.ai), non-interactive mode, and with training enabled.- Parameters:
driver- TheRemoteWebDriverto wrapapiKey- Your API key, acquired from smartdriver.dev-tools.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
SmartDriver, for chaining convenience.
-
execute
-
execute
-
getContext
-
getContextHandles
-
getExecuteMethod
-
getOrientation
-
getRemoteAddress
-
isBrowser
public boolean isBrowser() -
location
-
rotate
-
rotate
-
rotation
-
setLocation
-
executeAsyncScript
-
executeScript
-
getKeyboard
-
getMouse
-
manage
-
switchTo
-
get
-
findElement
-
findElement
-
findElements
-
getCapabilities
-
getCommandExecutor
-
getCurrentUrl
-
getErrorHandler
-
getFileDetector
-
getPageSource
-
getScreenshotAs
-
getSessionId
-
getTitle
-
getWindowHandle
-
getWindowHandles
-
perform
-
quit
public void quit() -
resetInputState
public void resetInputState() -
setErrorHandler
-
setFileDetector
-
setLogLevel
-
toString
-
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. Please usefindElementByElementName(String)instead.- Parameters:
elementName- The label name of the element to be classified.- Returns:
- An element associated with
elementName. Throws NoSuchElementException otherwise.
-
findElementByElementName
Finds an element byelementName.- Parameters:
elementName- The label name of the element to be classified.- Returns:
- An element associated with
elementName. Throws NoSuchElementException otherwise.
-
findByAI
Finds an elements byelementName. Uses visual AI to find the element.- Parameters:
elementName- The label name of the element to be classified.- Returns:
- An element associated with
elementName. Throws NoSuchElementException otherwise.
-
scrollToElement
-
scrollPage
public void scrollPage(int amount) -
close
public void close()
-