java - 我无法使用 selenium webdriver 在下拉列表中选择复选框
问题描述
看起来像这样 id("ctl05_cbMulti_DropDown")/div[@class="rcbScroll rcbWidth"]/ul[@class="rcbList"]/li[@class="rcbHovered"]/label[1]/input[@类="rcbCheckBox"]
这些都不起作用
司机。findElement(By.xpath("(//input[@type='checkbox'])[2]")).click(); 或 driver.findElement(By.id("ctl05_ctl03_cblUser_Input")).sendKeys("Smith, John");
解决方案
我在您的第一行代码中看到了一些错误。您不应该在 xpath 中传递“(”。
正确的代码应该是:
new WebDriverWait(driver, 30).until(ExpectedConditions.ElementToBeClickable (By.xpath("//input[@type='checkbox'][2]")));
driver. findElement(By.xpath("//input[@type='checkbox'][2]").click();
推荐阅读
- node.js - 使用服务器到服务器通信的另一台服务器上的 Nodejs 子进程
- javascript - 即使我没有错误,我的模拟时钟也无法处理 java 脚本
- c# - 在包含 Picker 的自定义控件中绑定 ItemSource 属性
- javascript - Uncaught (in promise) SyntaxError: Unexpected end of JSON input when fetch get data
- c - 在不同的头文件中使用同名的宏
- google-calendar-api - Google Calendar API:当会议在其日历中不存在时,用户作为与会者存在
- c# - 执行 inkCanvas1.Strokes.Erase() 后的 WPF-InkCanvas 撤消操作
- java - Cytoscape java:将边缘一直绘制到节点的中心
- c# - c# asp.net 身份和自定义角色
- yii2 - 如何更改 yii2 Query Builder 的数据库名称