Home > Articles

This chapter is from the book

This chapter is from the book

Debugging and Testing Using External Tools

There’s a very active partner community supporting Cordova with additional tools for Cordova developers. In this section, I introduce a couple of the more popular tools that help developers test and debug Cordova applications. This is by no means a complete list of options; refer to the PhoneGap Tools page (http://phonegap.com/tool) for information on additional tools that might be available. Some built-in debugging tools are also available with several of the mobile SDKs. These tools are covered in the individual chapters for each mobile OS (Chapters 7 through 10).

Debugging Applications with Weinre

Web Inspector Remote (weinre) is a community-built remote debugger for web pages. It was donated to the PhoneGap project and is currently implemented as part of the PhoneGap Build service. You can find the download files and instructions at http://people.apache.org/~pmuellr/weinre/docs/latest.

For Cordova development, it allows you to remotely debug a web application running in a Cordova container on a physical device or a device simulator. Weinre consists of a debug server, debug client, and debug target. The debug server runs on Macintosh or Windows, and the debug client runs in any compatible desktop browser.

To configure weinre, you need to perform a series of steps. The process begins with the server installation. Weinre is Node.js-based, and since we already have Node installed for the Cordova CLI, you can install the server using the following command:

npm install –g weinre

Unfortunately, on Macintosh weinre may not like your security configuration, so even though it’s not recommended, you may have to install weinre using sudo using the following command:

sudo npm install –g weinre

After the installation completes, you should see a message similar to the following:

weinre@2.0.0-pre-HH0SN197 /usr/local/lib/node_modules/weinre
├── underscore@1.3.3
├── coffee-script@1.3.3
├── nopt@1.0.10 (abbrev@1.0.4)
└── express@2.5.11 (qs@0.4.2, mime@1.2.4, mkdirp@0.3.0, connect@1.9.2)

With the installation completed, you can start weinre by issuing the following command in the terminal window:


When the server starts, it will indicate that it is running by displaying a message in the terminal window similar to the following:

2013-06-22T17:00:50.564Z weinre: starting server at http://localhost:8080

With the weinre server started, you use a browser-based client application to interact with the server and Cordova client application. Open your browser of choice (I recommend using Safari or Chrome) and point it to the URL shown on the server console when the weinre server started. For my development environment, I simply use:


The browser will connect to the weinre server and open the weinre debug client, which will display a page similar to the one shown in Figure 6.8.

Figure 6.8

Figure 6.8 Weinre Debug Client Startup Page

With the server and client running, you can now connect a Cordova application to the debug server by adding the following script tag to body section of the Cordova application’s index.html file:

<script src="https://debug_server:8080/target/target-script-min.js"></script>

You need to replace the debug_server portion of the URL with the correct host name or IP address for the debug server (the system running the weinre server). This makes the application into a weinre debug target and provides the Cordova application with the code needed to upload information to the weinre server as the application runs.

When using weinre with a device simulator, you can usually point the Cordova application to the local weinre server instance using

<script src="https://localhost:8080/target/target-script-min.js"></script>

The Android emulator, however, does not have the ability to connect to host-side resources using localhost, so for the Android emulator you must use the host address, as shown in the following example:

<script src=""></script>

When using weinre to debug a Cordova application running on a physical device, the device must be able to connect to your debug server. That means that the device must be able to “see” the server on the local network (most likely over a Wi-Fi connection), or the system running the weinre server must have a public facing IP address. Using a server host name of localhost will not work on a physical device; you must use an actual host name or IP address that is visible to the device.

After you have added the script tag to the Cordova application’s index.html file, run the application in the simulator or on a device. Nothing special will appear on the device screen—you can’t tell that the weinre debug client is running. However, if you switch to the browser running the weinre debug client and click the first link, shown in Figure 6.8 (the one labeled “debug client user interface”), you will initially see a page similar to the one shown in Figure 6.9.

Figure 6.9

Figure 6.9 Weinre Debug Client

In this example, the figure is indicating that no targets have connected yet, but as soon as I start my Cordova application, as long as it can connect to the weinre server, the debug client page will update and display the content shown in Figure 6.10.

Figure 6.10

Figure 6.10 Weinre Debug Client with an Application Connected

The debug client provides the means to view and optionally manipulate many of the page elements and other aspects of your application’s web content.

At this point, the different buttons across the top of the debug client are available to provide you with information about the debug target. For example, in Figure 6.11 you see the contents of the Elements page; it shows you the current HTML5 content running within the debug target.

Figure 6.11

Figure 6.11 Weinre Debug Client Resources Area

One of the cool features of weinre is that as you highlight the different code sections shown in Figure 6.11, weinre will highlight the corresponding content within the web application. So, for the HelloWorld3 application shown in Figure 6.11, highlighting the paragraph tag <p id= "appInfo">_</p> reveals, in the debug target, the section of the page shown in Figure 6.12. In this example, I kept the content of the paragraph tag collapsed in the debug client. You can click the black triangle to the left of the <p> element to see the complete HTML content.

Figure 6.12

Figure 6.12 Weinre Target Highlighting HTML Content

Using the debug client, you can access the following content areas:

  • Elements: The HTML, CSS, and JavaScript code for the application
  • Resources: Local resources used by the application, such as databases, local storage, and session storage
  • Network: Information about requests made using the XMLHTTPRequests (XHR)
  • Timeline: Events that occur within the target application
  • Console: Information written to the console using the console object described earlier in the chapter

The available documentation for Weinre is pretty light, but since the project’s capabilities are based on the Google Chrome Developer Tools, you can find additional information on the Google Code website at http://code.google.com/chrome/devtools/docs/overview.html.

Testing Applications Using the Ripple Emulator

The Ripple Emulator is a tool you can use to help with the initial testing of your Cordova application. Ripple is a browser-based emulator that can be used to emulate several different systems. Originally created by Tiny Hippos, which was then acquired by Research In Motion (now called BlackBerry), Ripple is now an incubator project at Apache. The problem with Ripple is that it’s been in beta for a very long time (almost two years by my counting), and the emulator is way behind on its Cordova support (supporting Cordova 2.0 when Cordova 2.8 was just released). Because of those limitations, I don’t go into too much detail about how Ripple works.

Ripple emulates the execution of the Cordova APIs within the browser container. You can use Ripple for quick testing of Cordova application features and UI during development, then switch to packaging/building Cordova applications and testing them on actual devices or device simulators for more thorough testing. Ripple is not designed to replace testing on real devices or simulators.

Since Ripple was a BlackBerry project for a while, it has a lot of features that help BlackBerry developers. You can, for example, test your BlackBerry WebWorks applications using Ripple, then package them into WebWorks applications directly from the browser. You can learn more about Ripple’s capabilities at https://developer.blackberry.com/html5/documentation/getting_started_with_ripple_1866966_11.html.

The emulator installs as a Google Chrome plugin, so you will need to install Chrome from www.google.com/chrome before you begin. Because Ripple is an incubator project and may become a full Apache project at any time, any URL I give you now may be invalid by the time you read this. So, to install Ripple, you should point your browser to http://emulate.phonagep.com. Follow the links on that page to download and install Ripple in your instance of the Chrome browser.

Once you have Ripple installed, you must enable file access for Ripple. In Chrome, open the settings page, then select the Extensions section. In the list of plugins that appears, enable the “Allow access to file URLs” option, shown in Figure 6.13.

Figure 6.13

Figure 6.13 Enabling Ripple File Access in the Chrome

Once the browser is configured, open your application’s index.html file in the browser. You can press Ctrl-O on Windows or Command-O on Macintosh to open the File Open dialog. Once the page has loaded, you need to enable Ripple for the selected page. To do this, click the Ripple icon to the right of the browser’s address bar to open a window allowing you to enable Ripple for the loaded page. You can also append ?enableripple=true to the end of any URL to enable Ripple emulation for that page.

With Ripple enabled, the browser will display a page that prompts you to identify which type of emulation you wish to enable, as shown in Figure 6.14. As you can see, Ripple can emulate Apache Cordova plus several other platforms and frameworks. Click the Cordova 2.0 button to continue.

Figure 6.14

Figure 6.14 Ripple Emulation Platform Selection Page

At this point, Ripple will display a page with the content from the index.html file rendered within the boundaries of a simulated smartphone screen, as shown in Figure 6.15. Wrapped around the simulated smartphone are properties panes that can be used to configure options and status for the simulated smartphone, such as simulated device screen resolution, accelerometer, network, geolocation, and more.

Figure 6.15

Figure 6.15 Ripple Emulator Running a Cordova Application

You can click on each of the tabs to expand the options for the tab and make changes to the simulated device’s configuration. At this point, you would simply click around within the simulated smartphone screen and interact with the options presented within your application. When you find a problem or a change you want to make within the Cordova application, simply return to your HTML editor, make the necessary changes, write the changes to disk, then reload the page in the Chrome browser to continue with testing.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020