Posts

Showing posts from April, 2017

Migrate Protractor E2E tests to async / await

I'm really tired of long chains of .then() in Protractor E2E tests, especially when loops and checking conditions in loops are needed. Decided I need some motivation so took a look to the future: tried to migrate a small set of tests writing in async / await style. Installed latest Node.js (7.9.0) and Protractor (5.1.1). Here comes the first surprise. "Nothing works" after disabling Selenium promise manager in Protractor config. That's why: https://github.com/angular/protractor/issues/4186 Fortunately, the issue is fixed a few days ago here: https://github.com/angular/jasminewd/pull/87 Apply this fix to my local version of jasminewd and try again. "Everything works!" Well, at least browser opens the page. Lessons learned while rewriting code: Async / await is good! The code becomes much more readable and much more easier to maintain. Try / catch in async / await structures allow better error message handling, which is so important for E2E t...

Protractor brings window to foreground - solved

Web is full of questions "Protractor brings browser window to foreground, how to minimize it". Most of the answers are "this is default behaviour when taking screenshots from tests, you can do nothing if you are using Windows" (and headless browsers solution for testing on Linux). I have a very strange (well, at least haven't read it anywhere yet) story regarding the issue. I've been using Protractor since November, running my local tests on Windows 10, taking screenshots after each test with no issues. I was able to start long run of tests, minimize the browser window to background and continue working while tests were running. Suddenly this behaviour changed a few weeks ago. We've updated chromedriver almost at the same time, so thought it might be related. Googled a bit, found those "you cannot do anything about this answers" and decided "well, they finally fixed some bug and I'm experiencing what I've should from the very b...