Check if Element Exists , then click on that element

View: New views
1 Messages — Rating Filter:   Alert me  

Check if Element Exists , then click on that element

by Hernan Castagnola :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have the following code to click on a link of an specific page. I just want to click on that link if exists. For some reason this is not working. Does anyone know a better solution for this?

static class PictureGallery {

    public static def goTo = { url , category, ant ->
        Listing.goTo url, category, ant    
        ant.storeXPath(xpath:"boolean(//span[@id='listing-gallery-toggle'])", property:"elementPresent")
        ant.ifStep (test:"elementPresent"){
            ant.clickLink description:"Clicks picture Gallery Link", htmlId:'listing-gallery-toggle-gallery' , savePrefix:'picturegallery' , saveResponse:'true'
     
   }
    }
       
}

Thanks,


Hernan