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

- old
+ new

@@ -2,11 +2,11 @@ describe Watir::Element do describe '#present?' do before do - browser.goto(WatirSpec.url_for("wait.html", needs_server: true)) + browser.goto(WatirSpec.url_for("wait.html")) end it 'returns true if the element exists and is visible' do expect(browser.div(:id, 'foo')).to be_present end @@ -29,13 +29,31 @@ expect(browser.div(:id, 'foo')).to_not be_present end end + describe "#enabled?" do + before do + browser.goto(WatirSpec.url_for("forms_with_input_elements.html")) + end + + it "returns true if the element is enabled" do + expect(browser.element(name: 'new_user_submit')).to be_enabled + end + + it "returns false if the element is disabled" do + expect(browser.element(name: 'new_user_submit_disabled')).to_not be_enabled + end + + it "raises UnknownObjectException if the element doesn't exist" do + expect { browser.element(name: "no_such_name").enabled? }.to raise_error(Watir::Exception::UnknownObjectException) + end + end + describe "#reset!" do it "successfully relocates collection elements after a reset!" do - browser.goto(WatirSpec.url_for("wait.html", needs_server: true)) + browser.goto(WatirSpec.url_for("wait.html")) element = browser.div(:id, 'foo') expect(element).to exist browser.refresh expect(element.exist?).to be false unless Watir.always_locate? element.send :reset! @@ -43,11 +61,11 @@ end end describe "#exists?" do before do - browser.goto WatirSpec.url_for('removed_element.html', needs_server: true) + 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") @@ -91,11 +109,11 @@ end describe "#element_call" do it 'handles exceptions when taking an action on an element that goes stale during execution' do - browser.goto WatirSpec.url_for('removed_element.html', needs_server: true) + browser.goto WatirSpec.url_for('removed_element.html') watir_element = browser.div(id: "text") # simulate element going stale after assert_exists and before action taken allow(watir_element).to receive(:text) do @@ -117,10 +135,10 @@ not_compliant_on %i(webdriver firefox synthesized_events), %i(webdriver internet_explorer), %i(webdriver iphone), %i(webdriver safari) do it "should hover over the element" do - browser.goto WatirSpec.url_for('hover.html', needs_server: true) + browser.goto WatirSpec.url_for('hover.html') link = browser.a expect(link.style("font-size")).to eq "10px" link.hover expect(link.style("font-size")).to eq "20px"