我需要从禁用的文本框中获取值
这是我尝试过的
WebElement text= driver.findElement(By.id("text"));
System.out.println("text= " +ssn.getAttribute("value"));
<input _ngcontent-c10="" class="form-control ng-untouched ng-pristine" id="text" name="TEXT" placeholder="12345" type="text" disabled="">
正在打印这个
text = null
最佳答案
您的 input
元素没有 value
属性,因此 .getAttribute("value"));
毫无用处
您的元素具有以下属性:
- _ngcontent-c10
- 类(class)
- ID
- 姓名
- 占位符
- 类型
- 已禁用
这可能就是您的意思:
WebElement text = driver.findElement(By.xpath("//input[@id='text']"));
System.out.println("text= " +text.getAttribute("placeholder"));
它将得到12345
关于java - 我无法从禁用文本中获取文本值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57581979/