如何用 Selenium 返回整列?
我知道Selenium有一个内置方法 getTable("tableName.row.column") 可以方便地返回单元格。但是我怎样才能返回整列呢?
我直接尝试了 getText(),但是只返回了第一个单元格,
getText("//tbody[@id='recordsTable']/tr[contains(@class, 'someclass')]")
但是具有相同 Xpath 表达式的 getXpathCount() 显示有多个元素匹配。
getXpathCount("//tbody[@id='recordsTable']/tr[contains(@class, 'someclass')]") // result is 15
请各位好心人帮忙,非常感谢!
I know that Selenium has a built-in method getTable("tableName.row.column") can return a cell conveniently. However how can I return a whole column?
I've tried getText() directly, however only the first cell was returned,
getText("//tbody[@id='recordsTable']/tr[contains(@class, 'someclass')]")
But getXpathCount() with the same Xpath expression showed there're multiple elements matched.
getXpathCount("//tbody[@id='recordsTable']/tr[contains(@class, 'someclass')]") // result is 15
Please kindly help, many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要迭代所有匹配的元素并将它们存储在某个地方。
所以
这将遍历包含您想要的所有匹配项的表,然后存储它们以供以后使用
You will need to iterate through all the elements that match and store them somewhere.
so
This will go through the table with all the matches you want and then store them for later use