我在web应用程序中有以下html代码的下拉控件
<input class="dynamic-list-widget-input ui-widget ui-widget-content" title="" autocomplete="off" aria-invalid="false">
我尝试过通过xpath(相对/绝对)、cssSelector使用selenium网络驱动程序访问,但没有成功,我得到了以下异常
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='With-Attachment']/div[2]/div[2]/div[5]/div[1]/span/input"}
Command duration or timeout: 10.12 seconds
看起来您很可能为该输入元素获得了错误的xpath。
如果您使用的是Chrome,您可以执行以下操作:
- 右键单击网页中的元素
- 点击弹出菜单中的"检查元素"
- 右键单击右侧突出显示的html代码,然后单击"复制xpath"
您将获得该元素的xpath,并比较代码中的内容。