Skip to content

Instantly share code, notes, and snippets.

@Dkendal
Created August 10, 2016 21:25
Show Gist options
  • Save Dkendal/76bb5b92180dd7d2e42ebe9a2919a421 to your computer and use it in GitHub Desktop.
Save Dkendal/76bb5b92180dd7d2e42ebe9a2919a421 to your computer and use it in GitHub Desktop.
# 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
@Dkendal
Copy link
Author

Dkendal commented Aug 10, 2016

look up a cell in table with xpath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment