Skip to content

Automate hybrid WebViews

olef v3.18.0View Markdown

Outcome: inspect DOM elements, enter text, tap controls, evaluate JavaScript, and capture console errors across the native/WebView boundary.

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).

Open the Checkout screen, discover the app's WebView with Olef, fill the
promo code field inside the WebView, tap Apply, and report both the DOM state
and any JavaScript console errors or native dialogs blocking the page.
Terminal window
olef web targets --app com.example.app
olef web dump --app com.example.app

web dump pierces open Shadow DOM and same-origin iframes and returns compact interactive elements mapped to device-space screen coordinates.

Terminal window
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 5000

When 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”
Terminal window
olef web console --app com.example.app
olef web cookies --app com.example.app
olef 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.

  • Cross-origin iframes are subject to browser security boundaries.
  • Release builds with WebView debugging disabled do not expose DevTools sockets.
  • web eval executes inside the page context and can have side effects.

See the full command reference in olef web.