public void clickOnWebElement ( By by , int match , boolean scroll , boolean useJavaScriptToClick ) { WebElement webElement = null ; if ( useJavaScriptToClick ) { webElement = waiter . waitForWebElement ( by , match , Timeout . getSmallTimeout ( ) , false ) ; if ( webElement == null ) { Assert . fail ( "WebElement with " + webUtils . splitNameByUpperCase ( by . getClass ( ) . getSimpleName ( ) ) + ": '" + by . getValue ( ) + "' is not found!" ) ; } webUtils . executeJavaScript ( by , true ) ; return ; } WebElement webElementToClick = waiter . waitForWebElement ( by , match , Timeout . getSmallTimeout ( ) , scroll ) ; if ( webElementToClick == null ) { if ( match > 1 ) { Assert . fail ( match + " WebElements with " + webUtils . splitNameByUpperCase ( by . getClass ( ) . getSimpleName ( ) ) + ": '" + by . getValue ( ) + "' are not found!" ) ; } else { Assert . fail ( "WebElement with " + webUtils . splitNameByUpperCase ( by . getClass ( ) . getSimpleName ( ) ) + ": '" + by . getValue ( ) + "' is not found!" ) ; } } clickOnScreen ( webElementToClick . getLocationX ( ) , webElementToClick . getLocationY ( ) , null ) ; }
Clicks on a web element using the given By method .