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
Post a Comment