Catch the JavaScript exceptions thrown in the browser.

Usage

.captureBrowserExceptions(callback)

Parameters

Name Type description
callback function

Callback function to be called when a new exception has taken place.

Example

 describe('capture browser exceptions', function() {
  it('does', async function (browser) {
     await browser.captureBrowserExceptions((event) => {
       console.log('>>> Exception:', event);
     });

     await browser.navigateTo('https://duckduckgo.com/');
     const aboutLink = await browser.findElement('#logo_homepage_link');

       await browser.executeScript(function(aboutLink) {
       aboutLink.setAttribute('onclick', 'throw new Error("Hello world!")');
     }, [aboutLink]);

       await browser.click(aboutLink);
  });
});