JAVA Script Executor Code to Click on an Element

Click on an Element in Selenium WebDriver

Sometimes click() method does not work because two views are loaded at the same time on a page. In this case, we can use the JavascriptExecutor to get the work done.

Below is code to click on an element using Javascript Executor.


1
2
3
4
5
6
7
@FindBy(id = Checkbox.financialAssistanceAccountEmailId)
public WebElement financialAssistanceAccountEmail;

//Click to element

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click()", financialAssistanceAccountEmail);






Comments

Popular posts from this blog

SQL Day 11: Group By in SQL Server

SQL Day 2: Creating, Altering and Dropping a Database