Created
February 2, 2011 18:48
-
-
Save sohara/808159 to your computer and use it in GitHub Desktop.
step definition to test the contents of specific table row given a column heading and the contents of one of the cells in the row
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
# Locates a table cell based on given row and column content. | |
When /^(.*) in the "([^\"]*)" column of the "([^\"]*)" row$/ do |action, column_title, row_title| | |
col_number = 0 | |
all(:xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{column_title}')]]/th").each do |element| | |
col_number += 1 | |
break if element.has_content?(column_title) | |
end | |
within :xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{row_title}')]]/td[#{col_number}]" do | |
When action | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is exactly what I have been looking for but I'm a little confused about how to use it. I basically have a table and I know the column title that contains the value I want (to assign to a variable) along with a value within that row. (The row itself doesn't have a title) When I try to run it with cucumber I get an undefined error.
What would the cucumber look like?
When in the "A" column of the "B" row ?