7

I've been going through an Angular app I'm working on, testing out CRUD functionality using Protractor for all the different parts of the app. All CRUD pages have create/edit buttons, and the buttons, regardless of what page you're on, all open the same modal whether they are creating or editing.

I am inconsistently running into the issue above. I literally will run the test and it will give me this error and not open the modal, then I'll run it again, and it will open the modal and the same exact test will pass. Then try again to make sure and it fails again. ETC

It's pretty annoying to have the only issues with your tests seem to be an issue with the browser/test suite, and not the actual code. Just to be clear I'm testing this in Chrome.

What would be the way of handling this type of issue, where the problem is the inconsistency of the passing and failing? It's unclear to me exactly what setting needs to be fixed.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
jtbitt
  • 561
  • 1
  • 5
  • 18

1 Answers1

6

It is difficult to say without seeing and running your actual tests, but here are things to try:

  • maximize the browser window:

    browser.driver.manage().window().maximize();
    
  • disable all angular animations

  • increase the implicit wait timeout
  • use elementToBeClickable built-in Expected Condition:

    var EC = protractor.ExpectedConditions;
    var elm = element(by.id("myelement"));
    
    browser.wait(EC.elementToBeClickable(elm), 5000);
    
  • scroll into view of the element before clicking it:

    browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());
    
  • move to element before clicking:

    browser.actions().mouseMove(elm).click(elm).perform();
    
  • click via javascript:

    browser.executeScript("arguments[0].click();", elm.getWebElement());
    
Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • What ended up working for me with this specific problem was putting a .wait timeout every time a new modal was rendered during the test. I made it wait until one of the elements in the modal was clickable, then used .then to execute the rest of the tests that took place within that modal. This eliminated the issue 100% and consistently for all 7 pages of my page testing. Thanks for the help! – jtbitt Dec 25 '15 at 01:19