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

UnknownObjectException when checking existence of an adjacent element that does not exist #477

Open
jkotests opened this issue Feb 5, 2019 · 0 comments
Labels

Comments

@jkotests
Copy link
Collaborator

jkotests commented Feb 5, 2019

An UnknownObjectException occurs when:

  • Checking the existence (or presence) of an adjacent element (eg followig_sibling, preceding_sibling, etc) and
  • The element does not exist.

For example, given the following page, where the div does not have a following sibling:

<html>
  <body>
    <div id="abc">a</div>
  </body>
</html>

An exception occurs when checking if a following sibling exists:

class MyPage
	include PageObject

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

page = MyPage.new(browser)
page.abc_element.following_sibling.present?
#=> C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.16.5/lib/watir/elements/element.rb:798:in `rescue in element_call': timed out after 2 seconds, waiting for #<Watir::HTMLElement: located: false; {:id=>"abc", :tag_name=>"div"} --> {:adjacent=>:following, :index=>0}> to be located (Watir::Exception::UnknownObjectException)
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.16.5/lib/watir/elements/element.rb:815:in `element_call'
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.16.5/lib/watir/elements/element.rb:791:in `rescue in element_call'
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.16.5/lib/watir/elements/element.rb:815:in `element_call'
#=> 	from C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.16.5/lib/watir/elements/element.rb:123:in `tag_name'
#=> 	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:97:in `following_sibling'
@jkotests jkotests added the bug label Feb 5, 2019
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

1 participant