selenium - Selenium - xpath 定义
问题描述
我正在尝试使用以下 xpath 来复选框“处理中”
我正在使用以下代码,但得到一个No such Element Exception:
String ds = "//*[@id='ctl00_ctl00_Content_MainPlaceHolder_cblStatuses_1']";
driver.findElement(By.xpath(ds)).click();
解决方案
要完成和添加额外的安全层,您可以使用以下 XPath:
//table[@empowertype="CheckBoxList"][preceding::label[1][.="Statuses"]]//input[@type="checkbox" and @value="In Process"]
输出:1 个input
元素
推荐阅读
- mysql - 使用外键将 MySQL 代码转换为 PostgreSQL
- java - Android: fill a spinner data from the server dynamically
- php - Getting only one result for a "football matchup" per team per week
- node.js - Can't parse JSON because of trailing whitespaces in JSON String
- c# - 身份 asp.net 核心 3.0 - 未找到 IdentityDbContext
- mongodb - 选择什么数据库?
- python - 为什么我无法使用 PySpark 连接到 Kafka?获取找不到数据源“kafka”错误
- reactjs - React、Axios 和 Flask - AttributeError: 'NoneType' 对象没有属性 'get'
- node.js - 如何检查某个用户何时使用 socket.io 断开连接?
- python - 如何修复类型错误:需要浮点数?