I want to click a button using Javascript in Selenium webdriver

Solved 1 Answers 70 Views Selenium
1 1
I am using Selenium Webdriver for automation. I would like to know code to execute Javascript and click on an element.

1 Answer

Best answer
WebElement element = driver.findElement(/*Your find element By*/);
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
answered by (192 points)
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

We have resolved 1.2k+ Software Testing queries!

Top Contributors