public boolean tryClick ( final By by ) { LOGGER . info ( "Trying to click on {}" , by ) ; List < WebElement > elements = wef . timeout ( 2L ) . by ( by ) . findAll ( ) ; if ( elements . size ( ) > 0 ) { WebElement element = elements . get ( 0 ) ; checkTopmostElement ( by ) ; new Actions ( webDriver ) . moveToElement ( element ) . click ( ) . perform ( ) ; LOGGER . info ( "Click successful" ) ; return true ; } LOGGER . info ( "Click not successful" ) ; return false ; }
Tries to find and element and clicks on it if found . Uses a timeout of two seconds .