def select_row (row_contents)
self.class.cell(:row, :text => /#{row_contents}/i)
self.row_element.click
end
The change is, the cell
method should be called on the class
of the pageobject
since it is a class level method
Question
I am using Cheezy's page-object gem. It works wonderfully in most cases but I can't seem to utilize it when working with dynamically created elements. I have a method for clicking on a cell by passing the text contents of the cell to the method and identifying the element at the time of action
def select_row (row_contents)
cell(:row, :text => /#{row_contents}/i)
self.row.click
end
I'm fairly sure this isn't working because the element is not having methods generated for it at run time. Can someone show me a way to create elements with page-objects dynamically in this manner?
Solution
def select_row (row_contents)
self.class.cell(:row, :text => /#{row_contents}/i)
self.row_element.click
end
The change is, the cell
method should be called on the class
of the pageobject
since it is a class level method
OTHER TIPS
Note that you can locate elements similar to Watir by using the NestedElements. Your method could be simply written as:
def select_row(row_contents)
cell_element(:text => /#{row_contents}/i).click
end