-1

enter image description hereI 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.

Lipson T A
  • 49
  • 3
  • 9

1 Answers1

1

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.

Abhishek Dhoundiyal
  • 1,359
  • 1
  • 12
  • 19