我有我的DOM如下,
我想从上面的输入标记getText()
。 我尝试了下面的方法,但由于这是一个JSapplication
我无法getText
。 尽管文本在DOM
不可见,但在UI
对用户可见。
List values = driver.findElements(By.xpath("//input[@ng-model='controller.model.value']")); for(int i=0;i<values.size();i++) { String theTextIWant = values.get(0).getAttribute("ng-model"); System.out.println(theTextIWant); }
下面是我执行上述代码时得到的输出。
controller.model.value
controller.model.value
controller.model.value
从输出中我可以说它只是获取属性“ng-model”中存在的值,而不是UI
可见的实际文本。 请告知如何获取UI
可见的文本。
预期文本:
9161
韦斯利
乔特
当您使用ng-model
作为属性时,它仅用于在运行时从控制器获取模型值,并将此值设置为input
。 因此,您正在获取ng-model
属性而不是实际值。
实际上input
元素在value
属性中包含它们的值,所以你应该尝试如下: –
List values = driver.findElements(By.xpath("//input[@ng-model='controller.model.value']")); for(WebElement el : values) { String theTextIWant = el.getAttribute("value"); System.out.println(theTextIWant); }
希望能帮助到你…:)
需要了解更多jQuery教程分享如何从angularjs应用程序的输入字段中获取文本(),都可以关注jQuery技术分享栏目—计算机技术网(www.ctvol.com)!
以上就是jQuery教程分享如何从angularjs应用程序的输入字段中获取文本()相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/jquerytutorial/982043.html