Get Current Context:
Get the current context in which Appium is running
Retrieve the current context. This can be either NATIVE_APP
for the native context, or a web view context, which will be:
- iOS -
WEBVIEW_<id>
- Android -
WEBVIEW_<package name>
For information on contexts, see Appium's hybrid automation docs.
String context = driver.getContext();
Get All Contexts:
Get all the contexts available to automate
Retrieve all the contexts available to be automated. This will include, at least, the native context. There can also be zero or more web view contexts. For information on the format of the context names, see the get context documentation. mobile command mobile: getContexts
is available on iOS (XCUITest) and Android (UIAutomator2 and Espresso) to get more detailed contexts. For information on contexts, see Appium's hybrid automation docs.
Set<String> contextNames = driver.getContextHandles();
Set Current Context:
Set the context being automated
Set the current context to that passed in. If this is moving into a web view context it will involve attempting to connect to that web view:
- iOS - attempt to connect to the application through the remote debugger
- Android - start a Chromedriver process and begin a session to connect to the web view
For information on contexts, see Appium's hybrid automation docs.
Set<String> contextNames = driver.getContextHandles();
driver.context(contextNames.toArray()[1]);
// ...
driver.context("NATIVE_APP");
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.