spec/element_spec.rb in watir-webdriver-0.9.1 vs spec/element_spec.rb in watir-webdriver-0.9.2

- old
+ new

@@ -50,13 +50,15 @@ end describe "#reset!" do it "successfully relocates collection elements after a reset!" do browser.goto(WatirSpec.url_for("wait.html")) - element = browser.div(:id, 'foo') + element = browser.div(id: 'foo') expect(element).to exist browser.refresh + browser.div(id: 'foo').wait_until_present + expect(element.exist?).to be false unless Watir.always_locate? element.send :reset! expect(element).to exist end end @@ -64,50 +66,19 @@ describe "#exists?" do before do browser.goto WatirSpec.url_for('removed_element.html') end - it "does not propagate StaleElementReferenceErrors" 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 "returns false when an element from a collection becomes stale" do - button = browser.button(id: "remove-button") - text = browser.divs(id: "text").first + watir_element = browser.divs(id: "text").first + expect(watir_element).to exist - expect(text).to exist - button.click - expect(text).to_not exist - end - - it "returns false when an element becomes stale" 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 + expect(watir_element).to_not exist end - it "returns appropriate value when an ancestor element becomes stale" do - stale_element = browser.div(id: 'top').div(id: 'middle').div(id: 'bottom') - expect(stale_element.present?).to be true # look up and store @element for each element in hierarchy - - grandparent = stale_element.instance_variable_get('@parent').instance_variable_get('@parent').instance_variable_get('@element') - - # simulate element going stale during lookup - allow(grandparent).to receive('enabled?') { raise Selenium::WebDriver::Error::ObsoleteElementError } - - browser.refresh - expect(stale_element.present?).to be Watir.always_locate? - end end describe "#element_call" do it 'handles exceptions when taking an action on an element that goes stale during execution' do @@ -123,20 +94,17 @@ end if Watir.always_locate? expect { watir_element.text }.to_not raise_error else - expect { watir_element.text }.to raise_error Selenium::WebDriver::Error::StaleElementReferenceError + expect { watir_element.text }.to raise_error Watir::Exception::UnknownObjectException end end end describe "#hover" do - not_compliant_on %i(webdriver firefox synthesized_events), - %i(webdriver internet_explorer), - %i(webdriver iphone), - %i(webdriver safari) do + not_compliant_on :internet_explorer, :iphone, :safari do it "should hover over the element" do browser.goto WatirSpec.url_for('hover.html') link = browser.a expect(link.style("font-size")).to eq "10px"