JAVA Script Executor Code to get the Value (same as getText() method)

Get the element value using Javascript Executor in Selenium WebDriver

To get the text of an element we can also use the Javascript Executor. Below is the code to get the text and store in a String variable.



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

//To get value 

JavascriptExecutor executor = (JavascriptExecutor) driver;
String visit = (String) executor.executeScript("return arguments[0].value", financialAssistanceAccountEmail);

Comments

Popular posts from this blog

SQL Day 11: Group By in SQL Server

JAVA Script Executor Code to Click on an Element

SQL Day 2: Creating, Altering and Dropping a Database