Hybrid Apps & WebViews
Switch between native and WebView contexts for hybrid apps.
Switch to WebView context
java
// List all available contexts
Set<String> contexts = driver.getContextHandles();
for (String ctx : contexts) {
System.out.println(ctx); // NATIVE_APP, WEBVIEW_com.example.app
}
// Switch to WebView
driver.context("WEBVIEW_com.example.app");
// Now use regular Selenium-style locators
driver.findElement(By.id("web-button")).click();
// Switch back to native
driver.context("NATIVE_APP");