Test::Unit Assert throws error instead of sending "false" for existence of page element

37 views
Skip to first unread message

Abe Heward

unread,
Oct 5, 2011, 11:46:28 AM10/5/11
to watir-...@googlegroups.com
Hey guys,

I'm using watir-webdriver (0.3.3) and Test::Unit.

In my code I'm trying to validate that an object is NOT present on the page...

assert_equal(false, @browser.button(:id=>"post").exist?)

...However, instead of getting the "false" result for the .exist?, apparently it's throwing this selenium error:

Selenium::WebDriver::Error::ObsoleteElementError: Element not found in the cache

I suppose I can validate the non-existence of page elements in some other way, but shouldn't I just get a "false" returned for that .exist? method?

Jari Bakken

unread,
Oct 5, 2011, 3:52:13 PM10/5/11
to watir-...@googlegroups.com
Yes, it should. Can you provide a reduced example where that's not the case?

Abe Heward

unread,
Oct 6, 2011, 10:50:03 AM10/6/11
to watir-...@googlegroups.com
I did some more experimentation and this is what I found:

puts @browser.button(:id=>"post").exist?

...will return false (Note that this is expected, as there's not such a button on the page), whereas

puts @browser.frame(:index=>1).button(:id=>"post").exist?

Will throw the "element not found in the cache" error.  There *are* a few iframes on the page.

I hope that's enough additional information to help.
Reply all
Reply to author
Forward
0 new messages