2

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)

Jackie
  • 21,969
  • 32
  • 147
  • 289

1 Answers1

3

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
Justin Ko
  • 46,526
  • 5
  • 91
  • 101
  • I knew it was going to be something like that, I just didn't know where platform was located. Thank you I will test it out! – Jackie May 27 '16 at 13:11