We have recently started with writing WebDriver tests in JavaScript and I have to agree that the asynchronous execution is added an unneeded complexity.
Pro's:
- Same test-runner as other (front-end) unit-tests
- Everyone knows JavaScript (e.g. front-end development with Angular, Vue or React)
- If you use JavaScript (e.g. NodeJS) also on the back-end, sticking to one language makes sense
Con's:
- Asynchronous execution complexity
- Hard to Google issues as most Selenium/WebDriver stuff is in Java (adding JavaScript barely helps)
We picked JavaScript because Java is a no go as our back-end is in C#. Also experience learned me not to add more programming-languages to the stack, certainly not any the developers had no experience with. C# WebDriver issues are just as hard to Google as JavaScript. Also I think C# bindings are not on par with Java and JavaScript as they get less commits on github.
JavaScript UI test frameworks:
It is possible to hide the Async complexity with JavaScript test frameworks like:
- CodeceptJS
- Nightmare
- Nightwatch.js
- Cypress (Cypress replaces Selenium completely)
For now we chosen to not research or use these frameworks mainly because one of our other teams decided to use plain selenium-webdriver for their tests.
With Nightwatch.JS I created a minimal test (with PageObject model) and it worked pretty well.
Still some of these frameworks look promising and might be worth researching if you want to use JavaScript.