Reputation: 23519
I have the following widget...
class MdRadioButton < PageObject::Elements::RadioButton
extend PageObject::Accessors
label :title, :class => "control-label"
def select
self.click
end
def selected?
self.class_name.include? "md-checked"
end
end
PageObject.register_widget :md_radio_button , MdRadioButton, :element
Then I try to access the title like this...
md_radio_buttons(:rdio, :class => "my-radio")
...
rdio_elements.each do |option|
if option.title == alert_group
option.select
end
end
But when I option.title
I get...
undefined method `platform' for #<Watir::HTMLElement:0x162e57d8\>
option.select
works fine
Update
I tried this...
class MdRadioButton < PageObject::Elements::RadioButton
extend PageObject::Accessors
include PageObject
Now the .title
works but .select
does not.
wrong number of arguments (0 for 1)
Upvotes: 2
Views: 162
Reputation: 46836
For the accessor methods to work within a widget, they need to access the platform. This can be done by adding an attr_reader
:
class MdRadioButton < PageObject::Elements::RadioButton
extend PageObject::Accessors
attr_reader :platform
label :title, :class => "control-label"
def select
self.click
end
def selected?
self.class_name.include? "md-checked"
end
end
Upvotes: 3