power_settings_new

I want to click a button using Javascript in Selenium webdriver

by
asked
1 like 0 dislike
96 views
1 1
I am using Selenium Webdriver for automation. I would like to know code to execute Javascript and click on an element.

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.

1 Answer

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