Logging js errors with Selenium Webdriver

Imagine a world where your continuous integration server is failing, but everything is passing locally.

Sound familiar? Wish that you could just open the browser console and look to see if there were any errors?

Good news! this is a solved problem and something that you can put to use right now.

Solved problem? but I have googled around and there are 0 good instructions for how to do this

Well... here is the solution!

        var webdriver = require('selenium-webdriver');
        var browser = new webdriver.Builder()
          browserName: 'chrome'

        // write your awesome tests here

        // when you want logs
        (new webdriver.WebDriver.Logs(browser))
        .then(function (v) {
          v && v.length && console.log(v);

And just like that you will have JS and console errors reported to you on CI!

Sam Saccone @samccone