[英]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. 应用程序具有一个
text filed
,该文件显示了动态变化,在获取了产品重量的值(只读)之后,我无法从中读取值。 Here is the code: 这是代码:
WebElement input = driver.findElement(getLocator("Weight1Value"));
System.out.println(input.getAttribute("value"));
You can try JavascriptExecutor if the above is not working 如果以上方法无效,您可以尝试使用JavascriptExecutor
JavascriptExecutor jse = (JavascriptExecutor)driver;
String Text = (String) jse.executeScript("return arguments[0].value;",driver.findElement(getLocator("Weight1Value")));
@Arun, just made small change & it's working fine for me @Arun,只是做了一些小改变, 对我来说一切正常
JavascriptExecutor jse = (JavascriptExecutor)driver;
String Text = (String) jse.executeScript("return arguments[0].value;",driver.findElement(getLocator("Weight1Value")));
System.out.println(Text);
xpath
as well. xpath
也犯了错误。 all fixed now, thanks guys 现在都固定了,谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.