Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexed property child field is not being added correctly #306

Open
Kysis101 opened this issue Jul 2, 2015 · 3 comments
Open

Indexed property child field is not being added correctly #306

Kysis101 opened this issue Jul 2, 2015 · 3 comments
Labels

Comments

@Kysis101
Copy link

Kysis101 commented Jul 2, 2015

I have defined an index property in my page-object. All of these fields are working except the :name field. I renamed it to :physician_name which worked but the method isn't created when it is :name.
indexed_property(:physician_panel,[
[:p, :physician_tab, text: '%s Physician'],
[:td, :name, id: 'authSubmitView-physicianPanel-%sPhysicianTab-NameField'],
[:td, :npi, id: 'authSubmitView-physicianPanel-%sPhysicianTab-NPIField'],
[:td, :specialty, id: 'authSubmitView-physicianPanel-%sPhysicianTab-SpecialtyField'],
[:td, :address, id: 'authSubmitView-physicianPanel-%sPhysicianTab-AddressField'],
[:td, :tin, id: 'authSubmitView-physicianPanel-%sPhysicianTab-TINField'],
[:td, :group_name, id: 'authSubmitView-physicianPanel-%sPhysicianTab-GroupNameField'],
[:td, :city_state_zip, id: 'authSubmitView-physicianPanel-%sPhysicianTab-CityStateZipField'],
[:text_field, :contact_name, id: 'authSubmitView-physicianPanel-%sPhysicianTab-ContactNameField'],
[:text_field, :email, id: 'authSubmitView-physicianPanel-%sPhysicianTab-EmailField'],
[:text_field, :phone_number, id: 'authSubmitView-physicianPanel-%sPhysicianTab-PhoneField'],
[:text_field, :last_contact, id: 'authSubmitView-physicianPanel-%sPhysicianTab-LastContactField'],
[:text_field, :fax_number, id: 'authSubmitView-physicianPanel-%sPhysicianTab-FaxField']
])

@AlanLGuy
Copy link

AlanLGuy commented Jul 3, 2015

I've run into this problem as well.

Essentially, page-object does a check to make sure you are not overwriting an instance method on class Class before defining the property method, since Class already has an instance method :name, it doesn't define the property.

Unfortunately this fails silently rather than warning the user. I'm not sure it's a good idea to allow a property called :name to be declared, but there should probably be a warning of some sort rather than silently doing nothing.

@Kysis101
Copy link
Author

Kysis101 commented Jul 7, 2015

That was my first instinct as well but if this is the case then calling .name on the object in question shouldn't throw a No Method error right? name is also not present when I print the methods for the object in question.

@jkotests jkotests added the bug label Nov 21, 2018
@jkotests
Copy link
Collaborator

Example test case is below.

HTML:

<html>
  <body>
    <table>
      <tr>
        <td id="authSubmitView-physicianPanel-1PhysicianTab-NameField">a</td>
        <td id="authSubmitView-physicianPanel-1PhysicianTab-NPIField">b</td>
      </tr>
      <tr>
        <td id="authSubmitView-physicianPanel-2PhysicianTab-NameField">c</td>
        <td id="authSubmitView-physicianPanel-2PhysicianTab-NPIField">d</td>
      </tr>
    </table>
  </body>
</html>

Page-object code:

class MyPage
  include PageObject

  indexed_property(:physician_panel,[
    [:td, :name, id: 'authSubmitView-physicianPanel-%sPhysicianTab-NameField'],
    [:td, :npi, id: 'authSubmitView-physicianPanel-%sPhysicianTab-NPIField']
  ])
end

page = MyPage.new(browser)
p page.physician_panel[1].npi
#=> "b"
p page.physician_panel[1].name
#=> C:/Ruby24/lib/ruby/gems/2.4.0/gems/page-object-2.2.4/lib/page-object/elements/element.rb:180:in `name': undefined method `attribute' for #<Watir::Browser:0x3eb4dac6 closed=true> (NoMethodError)
#=> 	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/page-object-2.2.4/lib/page-object.rb:49:in `method_missing'
#=> 	from pageobject.rb:36:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants