如何在没有循环的情况下获取Capybara中具有行列值的特定表格单元格文本? [重复]

时间:2022-05-15 00:38:42

This question already has an answer here:

这个问题在这里已有答案:

How can get the text in a cell at position (row_no , col_no) of a table in Capybara? In Watir it was easy to fetch a table element and do table_element[2][3].

如何在Capybara中的表的位置(row_no,col_no)获取单元格中的文本?在Watir中,很容易获取表元素并执行table_element [2] [3]。

How can this be done in Capybara?

怎么能在Capybara完成?

1 个解决方案

#1


3  

Capybara also supports XPath for querying:

Capybara还支持XPath查询:

page.has_selector?(:xpath, '//table/tr[2]/td[3]')

There is this nice cheat sheet in case you want deepen your knowledge on how to traverse documents with XPath.

如果您想加深对如何使用XPath遍历文档的知识,可以使用这个很好的备忘单。

HTH.

HTH。

#1


3  

Capybara also supports XPath for querying:

Capybara还支持XPath查询:

page.has_selector?(:xpath, '//table/tr[2]/td[3]')

There is this nice cheat sheet in case you want deepen your knowledge on how to traverse documents with XPath.

如果您想加深对如何使用XPath遍历文档的知识,可以使用这个很好的备忘单。

HTH.

HTH。