AppiumDriver Basics
Get introduced to WebDriver basics and the methods available in it.
We'll cover the following...
About WebDriver
WebDriver
is an interface that acts as a bridge between commands (finding, clicking, typing keys, scrolling, etc.) and the device/browser. The communication happens using JSON-wire protocol over HTTP.
About AppiumDriver
AppiumDriver
is a generic implementation of the interface WebDriver
. In addition, we have specialized implementations like AndroidDriver
, IOSDriver
, etc., providing device type-specific commands.
The following table shows the methods that are available in AppiumDriver
:
Method | Description |
---|---|
driver.activateApp(bundleId) |
activates the given app if installed but not running, or if it is running in the background |
driver.close() |
close the current window/quitting the browser if it’s the last window currently open |
driver.closeApp() |
closes the app that was provided in the capabilities at session creation and quits the session |
driver.launchApp() |
launches the app provided in the capabilities |
driver.context(name) |
switches the focus of future commands, for this driver, to the context with the given name |
driver.execute(String driverCommand, Map<String, ?> parameters) |
executes the JSONWP command and returns a response |
driver.findElement(By) |
finds the first WebElement matching the given locator |
driver.findElements(By) |
finds all the WebElement matching the given locator |
driver.get(url) |
opens the given URL in the current browser tab |
driver.getTitle(url) |
gets the title of current browser tab/window |
driver.getCurrentUrl() |
returns the URL of the page currently loaded in the browser |
driver.getContext() |
gets the current context handle |
driver.getContextHandles() |
returns the set of context handles that can be used to iterate over available contexts |
driver.getWindowHandle() |
get the current window handle |
driver.getWindowHandles() |
returns the set of window handles which can be used to iterate over available handles |
driver.switchTo().frame(index or name) |
switches the control to the frame |