I maintain a complex Angular (1.5.x) application that is being E2E tested using Protractor (2.5.x). I am experiencing a problem with this approach, which presents primarily in t
Just Say No to More End-to-End Tests!
That said, here are the few things you can do to tackle our mutual merciless "flakiness" enemy:
selenium
and chromedriver
with ituse dragons browser.wait() with a set of built-in or custom Expected Conditions. This is probably by far the most reliable way to approach the problem. Unfortunately, this is use-case and problem specific, you would need to modify your actual tests in the problematic places. For example, if you need to click an element, wait for it to be clickable:
var EC = protractor.ExpectedConditions;
var elm = $("#myid");
browser.wait(EC.elementToBeClickable(elm), 5000);
elm.click();
maximize the browser window (to avoid random element not visible or not clickable errors). Put this to onPrepare()
:
browser.driver.manage().window().maximize();
browser.waitForAngular();
in problematic places. I am not sure why this helps but I've seen reports where it definitely helped to fix a flaky test.it()
block until done
is called in beforeEach()
There are also other problem-specific "tricks" like slow typing into the text box, clicking via JavaScript etc.