Module: WatirRobot::Table
- Included in:
- KeywordLibrary
- Defined in:
- lib/watir_robot/keywords/table.rb
Overview
Functionality related to HTMl tables, including headers, bodies, footers, and cells
Instance Method Summary collapse
-
#get_table_cell(loc, row, col) ⇒ String
Get contents of a single table cell.
-
#table_cell_should_contain(loc, row, col, text) ⇒ Object
Verify that table cell contains certain contents.
-
#table_column_should_contain(loc, col, text) ⇒ Object
Verify that a table column contains certain contents.
-
#table_header_should_contain(loc, text) ⇒ Object
Verify that a table’s header contains certain contents.
-
#table_row_should_contain(loc, row, text) ⇒ Object
Verify that a table row conatins certain contents.
-
#table_should_contain(loc, text) ⇒ Object
Verify that certain content is contained somewhere within an entire HTML table.
Instance Method Details
#get_table_cell(loc, row, col) ⇒ String
Get contents of a single table cell
18 19 20 21 22 |
# File 'lib/watir_robot/keywords/table.rb', line 18 def get_table_cell(loc, row, col) row = row.to_i - 1 col = col.to_i - 1 @browser.table(parse_location(loc))[row][col].text end |
#table_cell_should_contain(loc, row, col, text) ⇒ Object
Verify that table cell contains certain contents
35 36 37 38 39 40 |
# File 'lib/watir_robot/keywords/table.rb', line 35 def table_cell_should_contain(loc, row, col, text) row = row.to_i - 1 col = col.to_i - 1 raise(ElementMatchError, "The table cell at row #{row} and column #{col}, located in the table at #{loc}, does not contain the text #{text}") unless @browser.table(parse_location(loc))[row][col].text.include? text end |
#table_column_should_contain(loc, col, text) ⇒ Object
Verify that a table column contains certain contents
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/watir_robot/keywords/table.rb', line 49 def table_column_should_contain(loc, col, text) # There's no "nice" way to do this, so we run through each row and snag # the cell at offset y col = col.to_i - 1 content = '' @browser.table(parse_location(loc)).rows.each do |row| content << ' ' content << row[col].text end raise(Exception::ElementMatchError, "The table column number #{c} in the table located at #{loc} does not contain the text #{text}") unless content.include? text end |
#table_header_should_contain(loc, text) ⇒ Object
Verify that a table’s header contains certain contents
69 70 71 72 |
# File 'lib/watir_robot/keywords/table.rb', line 69 def table_header_should_contain(loc, text) raise(Exception::ElementMatchError, "The table header of the table located at #{loc} does not contain the text #{text}") unless @browser.table(parse_location(loc)).thead.text.include? text end |
#table_row_should_contain(loc, row, text) ⇒ Object
Verify that a table row conatins certain contents
81 82 83 84 85 |
# File 'lib/watir_robot/keywords/table.rb', line 81 def table_row_should_contain(loc, row, text) row = row.to_i - 1 raise(Exception::ElementMatchError, "The table row number #{row} in the table located at #{loc} does not contain the text #{text}") unless @browser.table(parse_location(loc))[row].text.include? text end |
#table_should_contain(loc, text) ⇒ Object
Verify that certain content is contained somewhere within an entire HTML table
93 94 95 96 |
# File 'lib/watir_robot/keywords/table.rb', line 93 def table_should_contain(loc, text) raise(Exception::ElementMatchError, "The table located at #{loc} does not contain the text #{text}") unless @browser.table(parse_location(loc)).text.include? text end |