フレームに要素が存在するかどうかを確認しようとすると、実際には存在しない場合watir
、例外が発生します。
> main_frame.exist?
=> true
> main_frame.table(:id => "Table_1").exist?
=> true
> main_frame.table(:id => "Table_2").exist?
Selenium::WebDriver::Error::StaleElementReferenceError: Element belongs to a different frame than the current one - switch to its containing frame to use it
from [remote server] resource://fxdriver/modules/web_element_cache.js:5634:in `unknown'
from [remote server] file:///tmp/webdriver-profile20120531-5558-h7vd7r/extensions/fxdriver@googlecode.com/components/driver_component.js:5329:in `unknown'
from [remote server] file:///tmp/webdriver-profile20120531-5558-h7vd7r/extensions/fxdriver@googlecode.com/components/driver_component.js:6623:in `unknown'
from [remote server] file:///tmp/webdriver-profile20120531-5558-h7vd7r/extensions/fxdriver@googlecode.com/components/command_processor.js:9924:in `unknown'
from [remote server] file:///tmp/webdriver-profile20120531-5558-h7vd7r/extensions/fxdriver@googlecode.com/components/command_processor.js:9929:in `unknown'
from [remote server] file:///tmp/webdriver-profile20120531-5558-h7vd7r/extensions/fxdriver@googlecode.com/components/command_processor.js:9875:in `unknown'
from /home/raincole/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.22.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
from /home/raincole/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.22.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
from /home/raincole/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.22.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
...
でも…返してはいけないのfalse
?なぜ例外?