javascript - 用于识别复选框的正确 xpath

标签 javascript html eclipse selenium-webdriver

我正在尝试使用xpath编写一个selenium脚本来单击复选框,但无法执行该操作,而是收到错误

Element is not clickable at point (210.5, 616). Other element would receive the click: Command duration or timeout: 75 milliseconds

html:

<div style="float:left;">
<label class="enhanced-checkbox" for="lender_user_privacy">
<i class="icon"/>
</label>
<input id="lender_user_privacy" class="ui-helper-hidden-accessible" type="checkbox" value="1" required="required" name="lender_user[privacy]"/>
</div>

x路径:

driver.findElement(By.xpath("//input[@id = 'lender_user_privacy']")).click();

注意:您能否建议我正确的 xpath 来单击复选框,因为当我编写上述 xpath

时,我收到上述错误

最佳答案

考虑到注释,要导航回父级,您可以使用 xpath 的父级表达式 /..。 如果 .//input[@id='lender_user_privacy'] 正在识别您的标签,即“复选框的子项”,那么您可以使用访问该复选框

.//input[@id='lender_user_privacy']/..

作为你的xpath。但是,考虑到您收到的错误,等待很可能是必要的。

关于javascript - 用于识别复选框的正确 xpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38991047/

相关文章:

javascript - 使用babel-node调试ES6 Node.js应用程序

javascript - .getImageData() 具有背景图像属性?

java - 我无法导入 gradle 项目 Eclipse。 "Finish"按钮什么都不做

c++ - 如何使用 eclipse 控制台输入数据? (c++)

javascript - 带有组合框的第二列

java - jar 中的类可以使用不同 jar 中的类吗

javascript - 在没有 getJSON 的情况下从 Javascript 中的枚举 JSON 子数组中检索数据

javascript - 字符串替换不起作用?

Javascript 总和返回 NaN 错误

javascript - 多图片src路径切换