How to Test WebView Integration in Mobile Apps
WebView is an embedded browser inside a native app. It is handy for displaying HTML content, third-party login, legal docs, or hybrid UI. It is also a frequent source of bugs — navigation, security, c
WebView is an embedded browser inside a native app. It is handy for displaying HTML content, third-party login, legal docs, or hybrid UI. It is also a frequent source of bugs — navigation, security, communication with native code, performance, accessibility — each with its own pitfalls. This guide covers the test matrix.
What to test
Navigation
- URL loads within 3 seconds on 4G
- Back navigation works (either native back or WebView history)
- Forward navigation works (if exposed)
- External links open in system browser, not in-WebView
- Redirects handled correctly (including JavaScript redirects)
- Page title propagates to app nav bar
Rendering
- Content fits viewport, no horizontal scroll
- Fonts render at system size
- Images load
- Videos play (especially inline, without fullscreen prompt)
- Dark mode respected (via
prefers-color-scheme) - Long content scrolls smoothly
JavaScript bridge
- Native method exposure works (Android:
@JavascriptInterface, iOS:WKScriptMessageHandler) - Bridge injection happens after DOMContentLoaded
- Bridge methods callable from JS
- JS returns handled in native
- Bridge secured — origin whitelist enforced
Input
- Text input fields receive focus
- Keyboard appears on focus
- Keyboard-avoidance layout adjusts
- Autocomplete / autofill works
- Copy / paste works
- Select / share works
Performance
- Cold WebView first paint under 1.5s
- JavaScript-heavy pages do not freeze main thread
- Memory usage reasonable (WebView can leak big)
- Backgrounding WebView does not kill it
Error states
- No network → clear error page, not browser default
- Page load failure → retry option
- SSL error → warning respected, not bypassed
- 404 page friendly
Security
- HTTPS enforced (no HTTP for sensitive content)
- Mixed content blocked
- JavaScript evaluation limited to trusted origins
- File:// access disabled unless needed
- Cookie scope limited to this app's WebView
- No file system access to app's private storage
- CORS restrictions enforced
- Cross-origin iframe sandboxed
Android specifics
WebView.setWebContentsDebuggingEnabled(false)in release- Target SDK 30+ compliance
safeBrowsingEnabledonsetAllowUniversalAccessFromFileURLs(false)— default but verify- Autofill provider integration
iOS specifics
WKWebViewnotUIWebView(deprecated)allowsContentJavaScriptscope- WebKit process isolation (default yes)
- ITP / tracker blocking per iOS defaults
Accessibility
- Screen reader (TalkBack, VoiceOver) reads WebView content
- Heading structure exposed
- Form fields labeled
- Focus moves logically via keyboard
Common production bugs
- External links trap user in WebView — no way out without force-close
- Cookies persist across sessions exposing PII
- Bridge method callable from any origin — malicious site can invoke native functions
- WebView memory leak on repeated open — app OOMs over session
- Dark mode not propagated — WebView stays light on dark-theme app
- File input not functional on Android —
onShowFileChoosernot implemented - Third-party cookies blocked in WKWebView — OAuth / embedded widgets break
How to test
Manual
- Load your content, try every link, fill forms, test both online and offline
- Use Chrome DevTools to remote-debug Android WebView (
chrome://inspect) - Use Safari Web Inspector to debug iOS WKWebView
- Test bridge calls from JS console
Automated
# Appium — switch context to WebView
contexts = driver.contexts
driver.switch_to.context("WEBVIEW_com.example.app")
# Now you can use standard web selectors
driver.find_element(By.ID, "login_btn").click()
driver.switch_to.context("NATIVE_APP")
How SUSA handles WebView
SUSA automatically detects WebView contexts and switches to drive them with web-like interactions (when WebView debugging is enabled). It also tests the native ↔ WebView boundary: transitions, back navigation, content rendering, and bridge calls via JS evaluation.
susatest-agent test hybridapp.apk --persona curious --steps 150
Security scanner checks for common WebView misconfigurations (allowFileAccess, JavaScript evaluation, origin restrictions).
Design patterns
Prefer native over WebView
Native screens are more accessible, perform better, and avoid WebView's entire bug class. Use WebView only for: dynamic content (legal, blog, help), third-party login, content that must match web exactly.
Communicate via typed messages
Do not expose broad @JavascriptInterface. Define a strict message schema; validate every message; reject anything not on the allowlist.
Clear WebView data on logout
Cookies, cache, local storage all persist by default. Clear them when user signs out.
WebView is useful but expensive. Budget the testing time accordingly.
Test Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free