follow me icons

Thursday, May 24, 2012

Check element exists in GEB

To check whether an element exists in a page using GEB:
   static content = {
        searchVisibleField(required: false) {$("#search-id")}
   }

    def isSearchVisible()
    {
        if (browser.searchVisibleField() == geb.navigator.EmptyNavigator.instance())  {
           false
        }
        else {
           true
        }
    }
searchVisibleField returns the instance of geb.navigator.EmptyNavigator class so we can use that to check whether an element exists or not in a page. Reference from The Book of GEB

1 comment: