我有以下小部件......
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
然后我尝试像这样访问标题......
md_radio_buttons(:rdio, :class => "my-radio")
...
rdio_elements.each do |option|
if option.title == alert_group
option.select
end
end
但当我option.title
时,我得到了......
未定义的方法`平台&#39;对于#&lt; Watir :: HTMLElement:0x162e57d8 \&gt;
option.select
工作正常
更新
我试过了......
class MdRadioButton < PageObject::Elements::RadioButton
extend PageObject::Accessors
include PageObject
现在.title
有效但.select
没有。
错误的参数数量(0表示1)
答案 0 :(得分:3)
要使访问者方法在窗口小部件中工作,他们需要访问该平台。这可以通过添加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