We write our e2e tests in JavaScript running on Node.js which allows us to use newer JavaScript/ECMAScript features like template literals.
We have a subset of our e2e tests – mainly signing up as a new customer – which we run a few times a day against Internet Explorer 11: our lowest supported IE version.
I recently added a function that sets a cookie to set the currency for a customer:
setCurrencyForPayments( currency ) { const setCookieCode = function( currencyValue ) { window.document.cookie = `landingpage_currency=${ currencyValue };domain=.wordpress.com`; } return this.driver.executeScript( setCookieCode, currency ); }
This code works perfectly when executing against Chrome or Firefox, but when it came to executing against IE11 I would see the following (rather unhelpful) error:
Uncaught JavascriptError: JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 69 milliseconds
I couldn’t work out what was causing this so I decided to take a break. On my break I realised that WebDriverJs is trying to execute a new JavaScript feature (template literals) against an older browser that doesn’t support it! Eureka!
So all I had to do was update our code to:
setCurrencyForPayments( currency ) { const setCookieCode = function( currencyValue ) { window.document.cookie = 'landingpage_currency=' + currencyValue + ';domain=.wordpress.com'; } return this.driver.executeScript( setCookieCode, currency ); }
and all our tests were happy against IE11 again 😊
Having not found a lot about this error or the cause I am hoping this blog post can help someone else out if they encounter this issue also.