Friday, December 30, 2011

Check element existance in Geb

In Geb, if you need to check if some element does exists on page or not the best looking way to do it is method isPresent(), so it can be called like:

!notNeededLink.present
otherLink.present

Of course if you plan to check non-existing elements like this they need to be defined as not required and with wait - false. For example:

notNeededLink(to: SomePage, required:false, wait: false) {$('a', text:'Some')}

5 comments:

  1. could it be applicable to a div.? I have a problem, I don't know how to check the div if present or not.

    ReplyDelete
  2. I'm using angularjs ng-show="variable that hold boolean from the Controller" to show div if the variable returns true...

    ReplyDelete
  3. Bro thank you, been trying to find this answer for a day lol.

    ReplyDelete
  4. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. script cek mutasi

    ReplyDelete