Xpath在硒中不起作用 [英] Xpath is not working in selenium
本文介绍了Xpath在硒中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使 Angular 2.0应用程序自动化.
HTML代码:
<input _hello="" class="myclass" formcontrolname="phoneCtrl" required="" sdcleave="" sdmutekeys="[0-9]" type="text" placeholder="Phone number">
当我尝试使用 xpath
定位器定位上方的元素时,它给了我下面提到的错误.
When I try to locate above element using xpath
locator, it gives me below mentioned error.
尝试代码:
//input[@class='myclass'][0]
错误:没有这样的元素:无法找到元素:{"method":"xpath","selector":"//input [@ class ='myclass'] [0]"}(.. >
有人可以在这个问题上帮助我吗?
Can anyone help me on this issue?
推荐答案
使用 xpath定位器
说明:使用< input>
标记的 placeholder
属性.
//input[@placeholder='Phone number']
在 java
中,您可以这样做.
driver.findElement(By.xpath("//input[@placeholder='Phone number']")).sendKeys("1234567890");
这篇关于Xpath在硒中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文