Capturing Browser Errors and Logs in Android Web/Hybrid Apps

February 02, 2026 · 7 min read · Mobile Testing

HeadSpin Platform
Automated & amp; manual testing made easy through data skill insights.
Differentiating potentiality:
  • Extensive end-to-end mechanisation of QA process
  • Comparative analysis of app execution against peers
  • Uninterrupted monitoring of app performance using synthetic information for high availability of apps
  • Easy-to-use developer friendly platform
cloudtest go
Low-cost Existent Device Testing for Emerging Teams
cloudtest go
Low-cost Real Device Testing for Digital Enterprises
cloudtest go
The Ultimate Solution for a Powerful Blend of Functional & amp; Performance Testing!
cyol
TEM
New
Centralized mobile examination execution in cloud
cyol
Enhance Your Accessibility Testing With HeadSpin
cyol
Automate camera-based examination

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

retail

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

Capturing Browser Errors and Logs in Android Web/Hybrid AppsCapturing Browser Errors and Logs in Android Web/Hybrid Apps

Capturing Browser Errors and Logs in Android Web/Hybrid Apps

Published on
October 10, 2018
Updated on
Published on
May 20, 2022
Updated on
 by 
 Jonathan LippsJonathan Lipps
Jonathan Lipps

We & # x27; ve already seen how to; the like can be done for Android! The technique is largely similar but varies in some respects. As a reminder of why we might want to catch logarithm and errors from a browser, we could:

  1. Get under-the-hood information from our app that modulates the way our trial works.
  2. Store the logs for future reference; we could afford them to an app dev if a test fails, and they might be capable to use the logs to pinpoint the nature of an otherwise disconcert bug.

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

HeadSpin ’ s global device base enable mobile, and browser test on hundreds of real devices deployed worldwide.!

And of trend, simply as in the iOS universe, we & # x27; re not restrict to capturing console logs; we could create sure any JavaScript fault that are thrown get attached to the console as good, so we track those too (using a little drudge likewindow.onerror = console.error.bind (console)or like).

Remotely examination and debug mobile, web, audio and video coating on thousands of iOS device around the world.!

But let & # x27; s hop to the action. With iOS there was some complexity where we used a non-standardsafariConsolelog type and had to parse some JSON to get the literal data, with Android we can lead reward of the fact that Chrome mechanization happens via Chromedriver, which supports the full WebDriver protocol all on its own. Given that, we can just get a request for thebrowser log type:

driver.manage () .logs () .get (`` browser '');
Check out:

This returns a list ofLogEntry objects, and for each one we can retrieve its content (and, say, print it to the depot):

for (LogEntry entry: driver.manage () .logs () .get (`` browser '')) {System.out.println (entry.getMessage ());}

That & # x27; s all there is to it, in terms of the test codification itself. However, we do need to use a specialloggingPrefscapability to convert Chromedriver to turn on capturing of the browser log for us. In it simplest form, theloggingPrefscapability is an object specifying log types and log levels. For our purposes it ends up look like:

{`` loggingPrefs '': {`` browser '': `` ALL ''}}
Also check:

But in Java-client-world, we can make up this little structure utilise classes and constants instead! That way our IDE can guide us to the correct structure without having to remember strings like & quot; loggingPrefs & quot;:

LoggingPreferences logPrefs = new LoggingPreferences (); logPrefs.enable (LogType.BROWSER, Level.ALL); capabilities.setCapability (CapabilityType.LOGGING_PREFS, logPrefs);

With this capability set,browser log retrieval will work, regardless of whether you & # x27; re automating Chrome itself or a intercrossed app. The code sampling for this edition is essentially the same as for the iOS equivalent, so I added a hybrid exam merely to demo that it works equally easily with hybrid apps (though of class we experience to exchange into the web setting before making the outcry to get the browser logs). Here & # x27; s the full exemplar (which you can also viewon GitHub):

import io.appium.java_client.AppiumDriver; import io.appium.java_client.MobileBy; import io.appium.java_client.android.AndroidDriver; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.logging.Level; import javax.annotation.Nullable; import org.junit.After; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.logging.LogEntry; significance org.openqa.selenium.logging.LogType; import org.openqa.selenium.logging.LoggingPreferences; import org.openqa.selenium.remote.CapabilityType; importation org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class Edition038_Android_Web_Console {individual AndroidDriver driver; individual String APP_ANDROID = `` https: //github.com/cloudgrey-io/the-app/releases/download/v1.7.1/TheApp-v1.7.1.apk ''; private static By hybridScreen = MobileBy.AccessibilityId (`` Webview Demo ''); private electrostatic By urlInput = MobileBy.AccessibilityId (`` urlInput ''); @ After public void tearDown () {if (driver! = null) {driver.quit ();}} @ Nullable private String getWebContext (AppiumDriver driver) {ArrayListcontexts = new ArrayList (driver.getContextHandles ()); for (String context: contexts) {if (! context.equals (`` NATIVE_APP '')) {return circumstance;}} return void;} @ Test public nullity testLogging_Chrome () throws MalformedURLException {DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` platformName '', `` Android ''); capabilities.setCapability (`` automationName '', `` UiAutomator2 ''); capabilities.setCapability (`` deviceName '', `` Android Emulator ''); capabilities.setCapability (`` browserName '', `` Chrome ''); LoggingPreferences logPrefs = new LoggingPreferences (); logPrefs.enable (LogType.BROWSER, Level.ALL); capabilities.setCapability (CapabilityType.LOGGING_PREFS, logPrefs); driver = new AndroidDriver < > (new URL (`` http: //localhost:4723/wd/hub ''), potentiality); loggingRoutine (driver);} @ Test public void testLogging_Hybrid () throws MalformedURLException {DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` platformName '', `` Android ''); capabilities.setCapability (`` automationName '', `` UiAutomator2 ''); capabilities.setCapability (`` deviceName '', `` Android Emulator ''); capabilities.setCapability (`` app '', APP_ANDROID); LoggingPreferences logPrefs = new LoggingPreferences (); logPrefs.enable (LogType.BROWSER, Level.ALL); capabilities.setCapability (CapabilityType.LOGGING_PREFS, logPrefs); driver = new AndroidDriver < > (new URL (`` http: //localhost:4723/wd/hub ''), capabilities); WebDriverWait look = new WebDriverWait (driver, 10); // get to webview screen and enter webview mode wait.until (ExpectedConditions.presenceOfElementLocated (hybridScreen)) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (urlInput)); driver.context (getWebContext (driver)); // now we can run the same routine as for the browser loggingRoutine (driver);} public null loggingRoutine (AndroidDriver driver) {driver.get (`` https: //appiumpro.com/test ''); driver.executeScript (`` window.onerror=console.error.bind (console) ''); driver.executeScript (`` console.log ('foo. '); ''); driver.executeScript (`` console.warn ('bar? '); ''); driver.findElementById (`` jsErrLink '') .click (); for (LogEntry entry: driver.manage () .logs () .get (`` browser '')) {System.out.println (entry.getMessage ());}}}
Author & # x27; s Profile

Jonathan Lipps

LinkedIn
Author & # x27; s Profile

Piali Mazumdar

Lead, Content Marketing, HeadSpin Inc.

Piali is a dynamic and results-driven Content Marketing Specialist with 8+ years of experience in craft engaging narratives and market collateral across various industry. She excels in collaborating with cross-functional teams to develop innovative content strategies and deliver compelling, authentic, and impactful content that resonate with target hearing and enhances brand genuineness.

LinkedIn

Capturing Browser Errors and Logs in Android Web/Hybrid Apps

4 Parts

regression intelligence blog
-

Regression Intelligence practical guide for advanced users (Part 3)

Coming Soon
Regression Intelligence practical guide for advanced users
-

Regression Intelligence practical guide for innovative user (Part 4)

Coming Soon

Discover how HeadSpin can empower your business with superior test capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, gaining a competitory edge
faster development cycles
Boost developer/QA productivity with faster development cycle
automated buil-over-build regression testing
Automate build-over-build regression testing for logical results
gain better visibility into functional & performance issues
Gain best profile into functional and performance issues
reduce mean time
Reduce base time to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate audio, video, and content quality of experience (QoE) effortlessly
The trusted choice for ball-shaped enterprises
Adobe
Hargreaves Lansdown
Truecaller
Crazylabs
Nedbank
Numeracle
Veryon
Close

Discover how HeadSpin can empower your business with superior testing capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, gaining a private-enterprise edge
faster development cycles
Boost developer/QA productivity with quicker ontogeny rhythm
automated buil-over-build regression testing
Automate build-over-build regression quiz for consistent answer
gain better visibility into functional & performance issues
Gain best visibility into functional and performance issues
reduce mean time
Reduce mean time to identify/resolve during test, QA, and product
evaluate audio, video & qoe
Evaluate audio, video, and contented quality of experience (QoE) effortlessly
The sure choice for global enterprises
Close

Discover how HeadSpin can empower your business with superior testing capacity

Our Platform enable you to:
accelerate time-to-market
Accelerate time-to-market, benefit a militant edge
faster development cycles
Boost developer/QA productivity with faster maturation round
automated buil-over-build regression testing
Automate build-over-build fixation testing for reproducible effect
gain better visibility into functional & performance issues
Gain best visibility into functional and performance issues
reduce mean time
Reduce mean time to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate audio, video, and contented quality of experience (QoE) effortlessly
The trusted selection for planetary go-ahead
Close

Connet Now

Wipro LogoVMLYR Logo
Close
Book a Meeting
Products
footer down arrow
Solutions
footer down arrow
Industries
footer down arrow
Features
footer down arrow
Support
footer down arrow
Resource Center
footer down arrow
Why Choose HeadSpin?
footer down arrow
Copyright © 2026 HeadSpin, Inc. All Rights Reserved.

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

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