spec/element_spec.rb in watir-webdriver-0.6.10 vs spec/element_spec.rb in watir-webdriver-0.6.11

- old
+ new

@@ -29,19 +29,41 @@ expect(element).to exist end end describe "#exists?" do - it "should not propagate ObsoleteElementErrors" do + before do browser.goto WatirSpec.url_for('removed_element.html', :needs_server => true) + end + it "should not propagate ObsoleteElementErrors" do button = browser.button(:id => "remove-button") element = browser.div(:id => "text") expect(element).to exist button.click expect(element).to_not exist end + + it "should determine if element constructed with WebDriver element is stale" do + button = browser.button(:id => "remove-button") + text = browser.element(:element, browser.div(:id => "text").wd) + + expect(text).to exist + button.click + expect(text).to_not exist + end + + it "should handle element that becomes stale during lookup" do + wd_element = browser.div(:id => "text").wd + + # simulate element going stale during lookup + allow(browser.driver).to receive(:find_element).with(:id, 'text') { wd_element } + browser.refresh + + expect(browser.div(:id, 'text')).to_not exist + end + end describe "#hover" do not_compliant_on [:webdriver, :firefox, :synthesized_events], [:webdriver, :internet_explorer],