Automate hybrid WebViews
Outcome: inspect DOM elements, enter text, tap controls, evaluate JavaScript, and capture console errors across the native/WebView boundary.
Prerequisites
Section titled “Prerequisites”The target app must be debuggable and enable WebView debugging (WebView.setWebContentsDebuggingEnabled(true)). olef web runs host-side over ADB localabstract: sockets and is scoped strictly to --app by default (separate browsers on the device are excluded unless you pass --include-browsers).
Ask your agent
Section titled “Ask your agent”Open the Checkout screen, discover the app's WebView with Olef, fill thepromo code field inside the WebView, tap Apply, and report both the DOM stateand any JavaScript console errors or native dialogs blocking the page.1. Discover targets and inspect the DOM
Section titled “1. Discover targets and inspect the DOM”olef web targets --app com.example.appolef web dump --app com.example.appweb dump pierces open Shadow DOM and same-origin iframes and returns compact interactive elements mapped to device-space screen coordinates.
2. Find, act, and wait inside the WebView
Section titled “2. Find, act, and wait inside the WebView”olef web find --app com.example.app --css "#promo-code"olef web text "SAVE20" --app com.example.app --css "#promo-code"olef web tap --app com.example.app --text "Apply"olef web wait --app com.example.app --text "Discount applied" --timeout-ms 5000When Olef’s native device service is connected, web tap also checks for native Android overlays covering the WebView element—catching cases where a DOM node looks clickable in HTML but sits behind a native dialog or bottom sheet.
3. Inspect console logs, cookies, and JS state
Section titled “3. Inspect console logs, cookies, and JS state”olef web console --app com.example.appolef web cookies --app com.example.appolef web eval --app com.example.app --expr "document.title"Cookie values are masked by default; pass --values only when needed (and note --redact always masks them). Uncaught WebView JavaScript exceptions also surface automatically in olef why, so one triage call correlates native crashes, HTTP errors, and WebView JS failures together.
Limits
Section titled “Limits”- Cross-origin iframes are subject to browser security boundaries.
- Release builds with WebView debugging disabled do not expose DevTools sockets.
web evalexecutes inside the page context and can have side effects.
See the full command reference in olef web.