4

I'm coding my AngularJS test with protractor / JUnit

I'm willing to test that element is NOT present.

So far, I'm using the following :

  expect(elem.isPresent()).toBe(false);

This is working as expected, but it's way to slow. I'm not wiating for the element to change state from isPresent to isNotPresent, just to check at a certain moment of my tests that I do not have various element.

It is as important for me than testing that element are present.

My problem is that the several test of non presence, that are very simple are taking too much time; as it seems to wait for a timeout or something.

I'm willing to do that test of non presence as fast as possible.

Therefore, I tried different approch such as :

 - expect(element.all(locator).count()).toEqual(0)
 - ExpectedCondition : seems promising, but I do not see any condition for isNotPresent.

I'm running out of ideas so far, any suggestions will be much appreciated

Thank you for support

aorfevre
  • 5,034
  • 3
  • 21
  • 51

1 Answers1

3

What you can do is to reduce the implicit wait timeout:

onPrepare: function(){
    browser.manage().timeouts().implicitlyWait(2000);
},

Though check that it does not affect the other areas of your tests.


Another option would be to use browser.isElementPresent() instead which is the pure webdriver's implementation of the presence check and, hence, would help to avoid the protractor-to-angular sync:

expect(browser.isElementPresent(elem)).toBe(false);

Also see:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195