shashi j shashi j - 5 months ago 38
Java Question

How to do get text of read only text from Selenium webdriver java

Application has a

text filed
which displays dynamically changes, after getting value of the weight of a product,that is read only, I am not able to read the values from it. Here is the code:

WebElement input = driver.findElement(getLocator("Weight1Value"));
System.out.println(input.getAttribute("value"));

Answer

You can try JavascriptExecutor if the above is not working

JavascriptExecutor jse = (JavascriptExecutor)driver;
String Text = (String) jse.executeScript("return arguments[0].value;",driver.findElement(getLocator("Weight1Value"));