Capturing Browser Errors and Logs in iOS Web/Hybrid Apps

April 19, 2026 · 8 min read · Mobile Testing

HeadSpin Platform
Automated & amp; manual examination made easygoing through data science insights.
Differentiating capacity:
  • Wide end-to-end automation of QA process
  • Relative analysis of app performance against peers
  • Continuous monitoring of app performance using synthetic data for high availability of apps
  • Easy-to-use developer friendly platform
cloudtest go
Affordable Real 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 nomadic examination performance in cloud
cyol
Enhance Your Accessibility Testing With HeadSpin
cyol
Automate camera-based examination

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

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

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

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

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

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

retail

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

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

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

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

Capturing Browser Errors and Logs in iOS Web/Hybrid Apps

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

We & # x27; ve talked a few times about automate and apps with Appium. One characteristic of such apps is the power to write information to the browser console. Whether or not this console is seeable to the end exploiter is irrelevant -- -app developer ofttimes announce interesting information about the province of an app in the form of browser console message. It would be useful to be able to retrieve this info as part of our test, for two main reasons:

  1. To make affirmation on app state (for model if we & # x27; re look for a 3rd-party JS library to load, and the only way we have of determining its state is by inspecting the console)
  2. To salve the record of an app & # x27; s behavior during a tryout run for future review (for example to assist in debugging failed test, or in reporting bugs caught by a test).
Check out:

Something closely related to the second purpose is the demand to capture JSerrors; it & # x27; s extremely useful to detect whether the web/hybrid app has cast any errors during the course of a test! Using a unproblematic slight hack, it & # x27; s actually quite leisurely to get any JS error lumber to the browser console. We simply have to run this little bit of JS in the page:

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

window.onerror = console.error.bind (console);

This fundamentally tells the browser to direct info about any mistake it detects on the page to the console.

Read:

Of class, all of this is moot if there & # x27; s no way to use Appium to retrieve this info. Happily, there is! Let & # x27; s take a look at how to retrieve the browser logarithm for Safari (or any other iOS hybrid app).

We commence by using the log retrieval mechanics built into the Appium client (by way of the Selenium node include within), and specifying a particular, customlog type safariConsole:

driver.manage () .logs () .get (`` safariConsole '');

In Java, this will return aLogEntriesobject which contains a set of (you guessed it) log entries: one per console message which has be received since the last clip we retrieved the introduction. Each entry has certain information associated with it: amessage, a level and a timestamp. In the case ofsafariConsolelogs, the message is itself a JSON string, which contains lots of info (the console substance itself, a stack trace, and so on). This means that we & # x27; ll typically need to convert the content from its JSON string format into an aim we can work with in our code. Let & # x27; s say we wanted to publish out the numeric timestamp, the severity level, and the message of everything that & # x27; s been logged to the console. We can do so habituate the following code:

for (LogEntry entry: driver.manage () .logs () .get (`` safariConsole '')) {HashMapconsoleEntry = new Json () .toType (entry.getMessage (), Json.MAP_TYPE); System.out.println (String.format (`` % s [% s] % s '', entry.getTimestamp (), entry.getLevel (), consoleEntry.get (`` schoolbook '')));}

Essentially, what we & # x27; re doing is going through each entry in the list of debut, turning the substance into a key/value brace so we can extract specific data from it, and using some of the general entry API methods as well (to get the clip and severity point of the substance). Of course, this is just one exemplar of how we could use thedriver.manage () .logs ()feature. We could do all kinds of thing with it. But when would we want to do something like above? It would sit very naturally in some sort of teardown method. Instead of write to stdout, we could write the console messages to a file and salve it along with other test artifacts in case we need it after on to envision out why a test failed.

Also read:

We could too use thewindow.onerrorhack I exhibit above, to make sure that any JS fault are brought to our attention; we could even be real strict with our developer and automatically fail a test if anySEVERE-level log unveiling come through! We don & # x27; t even need our developers & # x27; permission to set up this slight error handler; we can do it ourselves usingexecuteScriptat the kickoff of our test:

driver.executeScript (`` window.onerror=console.error.bind (console); '');

(2 caveats hither with this simplistic hack: first, we & # x27; ll need to run this slight scriptafterthe page has loaded, which means we won & # x27; t catch erroneousness that happen on page load. Second, we & # x27; d overwrite any other handler attach to theonerror case, which might break the intended conduct of the app if such a handler was already in use).

Also check:

At any rate, apply thesafariConsolelog eccentric, we & # x27; re able to get all variety of occupy information from the browser console, whether in Safari or still intercrossed apps. Have a look at theentire code samplingto see how I & # x27; ve put everything together in the setting of a real-world illustration:

importation io.appium.java_client.ios.IOSDriver; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import org.junit.After; import org.junit.Before; import org.junit.Test; significance org.openqa.selenium.json.Json; import org.openqa.selenium.logging.LogEntry; import org.openqa.selenium.remote.DesiredCapabilities; public class Edition037_iOS_Web_Console {private IOSDriver driver; @ Before public void setUp () cast MalformedURLException {DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` platformName '', `` iOS ''); capabilities.setCapability (`` platformVersion '', `` 11.4 ''); capabilities.setCapability (`` deviceName '', `` iPhone 8 ''); capabilities.setCapability (`` browserName '', `` Safari ''); driver = new IOSDriver < > (new URL (`` http: //localhost:4723/wd/hub ''), capabilities);} @ After public vacancy tearDown () {if (driver! = null) {for (LogEntry introduction: driver.manage () .logs () .get (`` safariConsole '')) {HashMapconsoleEntry = new Json () .toType (entry.getMessage (), Json.MAP_TYPE); System.out.println (String.format (`` % s [% s] % s '', entry.getTimestamp (), entry.getLevel (), consoleEntry.get (`` text '')));} driver.quit ();}} @ Test world void testLogging () {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 ();}}
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+ days of experience in crafting occupy tale and marketing collateral across various industriousness. She excels in collaborating with cross-functional teams to develop innovative content strategies and deliver compelling, authentic, and impactful message that resonates with target hearing and enhances marque genuineness.

LinkedIn

Capturing Browser Errors and Logs in iOS 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 pragmatic guide for advanced users (Part 4)

Coming Soon

Discover how HeadSpin can empower your business with superior testing capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, win a competitive edge
faster development cycles
Boost developer/QA productivity with quicker ontogeny cycles
automated buil-over-build regression testing
Automate build-over-build regression testing for logical results
gain better visibility into functional & performance issues
Gain better 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 sure choice for ball-shaped enterprises
Adobe
Hargreaves Lansdown
Truecaller
Crazylabs
Nedbank
Numeracle
Veryon
Close

Discover how HeadSpin can empower your job with superior testing 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 consistent results
gain better visibility into functional & performance issues
Gain better visibility into functional and execution issues
reduce mean time
Reduce hateful clip to identify/resolve during test, QA, and product
evaluate audio, video & qoe
Evaluate audio, video, and content quality of experience (QoE) effortlessly
The trusted selection for global enterprises
Close

Discover how HeadSpin can gift your business with superior try capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, acquire a competitive edge
faster development cycles
Boost developer/QA productivity with faster ontogeny cycle
automated buil-over-build regression testing
Automate build-over-build regression testing for consistent results
gain better visibility into functional & performance issues
Gain better profile 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, picture, and contented quality of experience (QoE) effortlessly
The trusted pick for planetary enterprises
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