Created
August 10, 2016 21:25
-
-
Save Dkendal/76bb5b92180dd7d2e42ebe9a2919a421 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find a cell based on the _exact_ text in the column, and a row that | |
# _contains_ the row text. | |
def within_cell column, row | |
col_eq = "text()='#{column}'" | |
col_index = "count(//table//td[#{col_eq}]/preceding-sibling::*) + 1" | |
row_matches = "..//td/text()[contains(., '#{row}')]" | |
within(:xpath, "//table//td[#{col_index}][#{row_matches}]") { yield } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
look up a cell in table with xpath