Get Current Context
Retrieve the current context. This can be either NATIVE_APP for the native context, or a web view context, which will be:
iOS – WEBVIEW_
Android – WEBVIEW_
String context = driver.getContext();
Get All Contexts
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.
Set contextNames = driver.getContextHandles();
Set Current Context
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:
Set contextNames = driver.getContextHandles();
driver.context(contextNames.toArray()[1]);
// …
driver.context(“NATIVE_APP”);