How many ways to click on webElement In WebDriver?

You can use:

yourelement.sendKeys(Keys.RETURN) or .sendKeys(Keys.ENTER) : which is an equivalent of focusing that element and hitting RETURN/ENTER on that element

Also, There are methods to do this using Javacript but it is not usually recommended:

using the non-native Javascript Executor:

((JavascriptExecutor) driver).executeScript("arguments[0].click();", yourelement);

or by using Javascript Library:

JavascriptLibrary jsLib = new JavascriptLibrary();`
jsLib.callEmbeddedSelenium(driver, "triggerMouseEventAt", we, "click", "0,0");

Leave a Comment