0

I want to check to see if a label exists. Sometimes I expect it to be displayed "class.checkLabel(true)" and sometimes I want to check to make sure it is hidden "class.checkLabel(false)". When sending in "false", I am wasting a lot of time waiting for .isPresent to complete.

Is there a way to speed this up besides incorporating WebDriverWait?

public void checkLabel(boolean isLabelVisible) {
    boolean result = label.isPresent();
    Assert.assertEquals(isLabelVisible, result);
}
user2195411
  • 215
  • 2
  • 5
  • 20
  • 3
    Possible duplicate of [isElementPresent is very slow in case if element does not exist.](http://stackoverflow.com/questions/16075997/iselementpresent-is-very-slow-in-case-if-element-does-not-exist) – Yosef Weiner Jan 21 '17 at 22:06
  • 1
    You probably have an implicit wait you should get rid of before the findElement. Try the solution in the possible duplicate, if that won't work I'll post another solution. – Moshisho Jan 22 '17 at 08:15
  • Thanks all. I checked the possible dupe link (I searched, not sure how I missed that one). @Moshisho - Would like to see your solution too and compare, thanks – user2195411 Jan 23 '17 at 01:20
  • Do you have an implicit wait? anyways, I'd try these solutions if your case is different: http://stackoverflow.com/questions/7991522/selenium-webdriver-test-if-element-is-present – Moshisho Jan 23 '17 at 17:52

0 Answers0