c# - 如何在网格中的多个记录中选择第一条记录复选框?
问题描述
我在下面尝试过
IWebElement selectchk = driver.FindElement(By.XPath("//input[@type='checkbox' and starts-with(@id,'ctl00_UserContentArea_rgBulkSFA_ctl00_')]"));
但问题是网格中的所有复选框都以 Id 开头,因此所有复选框都被选中。请帮忙!
解决方案
试试这个 xpath,它只会给出列表的第一个元素:
driver.FindElement(By.XPath("(//input[@type='checkbox' and starts-with(@id,'ctl00_UserContentArea_rgBulkSFA_ctl00_')])[1]"));
推荐阅读
- java - 为什么我的累加器不增加并且总是返回零?
- visual-studio-code - 为什么“npm script”出现在我的资源管理器中?
- react-native - 什么可以使功能在模拟器上运行而不是在设备上运行?
- html - CSS:可视化隐藏y轴滚动条而不影响x轴滚动条
- html - 如何消除 React JS 中 Font Awesome Icon 和段落之间的差距?
- python-2.7 - 解决python包依赖
- swift - AvAudioEngine 可以播放和录音吗?
- javascript - 如何在 React JS 中像普通 Javascript 一样替换或删除字符串中的字符?
- unity3d - 参数值未从脚本发送到混合树(Unity 2020)
- typescript - 我在哪里可以获得 VpcLink ID?