Skip to content

Undefined method 'type' when the retrieved adjacent elements includes inputs #478

@jkotests

Description

@jkotests

For example, given the following page, which has an input adjacent to a div:

<html>
  <body>
    <label id="abc">a</label>
    <input type="checkbox">
  </body>
</html>

An exception will occur when trying to get the adjacent elements:

class MyPage
	include PageObject

	label(:abc, id: 'abc')
end

page = MyPage.new(browser)
page.abc_element.following_siblings
#=> C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.16.5/lib/watir/elements/element.rb:844:in `method_missing': undefined method `type' for #<Watir::Label: located: true; {:id=>"abc", :tag_name=>"label"}> (NoMethodError)
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/page-object-2.2.5/lib/page-object/elements/element.rb:185:in `pageobject_wrapper'
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/page-object-2.2.5/lib/page-object/elements/element.rb:131:in `block in following_siblings'
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.16.5/lib/watir/element_collection.rb:32:in `each'
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.16.5/lib/watir/element_collection.rb:32:in `each'
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/page-object-2.2.5/lib/page-object/elements/element.rb:131:in `collect'
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/page-object-2.2.5/lib/page-object/elements/element.rb:131:in `following_siblings'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions