I wanted to get the text inside the input tag which is not available in my HTML. So I have to use JS for getting the value. But I am getting null as the result when running in eclipse. I have added the HTML and Selenium code in the below screenshot.
1 Answer
In Javascript:
document.getElementById("estimatedDepositRate").value;
This can be achieve in selenium using JavascriptExecutor :
String estimatedDepositRate = ((JavascriptExecutor) driver).executeScript("return document.getElementById("estimatedDepositRate").value");
Normal Code:
driver.findElement(By.id("estimatedDepositRate")).getAttribute("value")
Note: Kindly cast the estimatedDepositRate value to String if you get any error.
driver.findElement(By.xpath("//input[@id = 'estimatedDepositRate']")).getAttribute("value")? You need to use javascript? off: That is an input, not textBoxInspect, that doesn't mean there is novalueproperty.