require 'spec_helper' describe "Web Objects" do let(:watir_browser) { mock_browser_for_watir } let(:watir_definition) { ::Symbiont::WebObjects::WebObject.new(watir_browser) } it "should retrieve the value of an attribute" do watir_browser.should_receive(:attribute_value).and_return(true) watir_definition.attribute("readonly").should be_true end it "should retrieve the style of a web object" do watir_browser.should_receive(:style).with('display').and_return("none") watir_definition.style('display').should == 'none' end it "should determine if a web object is enabled" do watir_browser.should_receive(:enabled?).and_return(true) watir_definition.enabled?.should == true end it "should determine if a web object is disabled" do watir_browser.should_receive(:enabled?).and_return(false) watir_definition.disabled?.should == true end it "should determine if a web object exists" do watir_browser.should_receive(:exists?).and_return(true) watir_definition.exists?.should == true end it "should determine if a web object does not exist" do watir_browser.should_receive(:exists?).and_return(false) watir_definition.exists?.should == false end it "should determine if a web object is visible" do watir_browser.should_receive(:visible?).and_return(true) watir_definition.visible?.should == true end it "should determine if a web object is not visible" do watir_browser.should_receive(:visible?).and_return(false) watir_definition.visible?.should == false end it "should return the text contained by a web object" do watir_browser.should_receive(:text).and_return("testing") watir_definition.text.should == "testing" end it "should simulate a click event on a web object" do watir_browser.should_receive(:click) watir_definition.click end it "should wait for a web object to be actionable" do watir_browser.should_receive(:wait_until_present).twice.with(5) watir_definition.when_actionable(5) watir_definition.when_present(5) end it "should reference a web object when it is actionable" do watir_browser.should_receive(:wait_until_present).with(5) web_object = watir_definition.when_actionable(5) web_object.should === watir_definition end it "should wait for a web object to become visible" do watir_browser.should_receive(:visible?).and_return(true) watir_definition.when_visible(5) end it "should reference a web object when it is visible" do watir_browser.should_receive(:visible?).and_return(true) web_object = watir_definition.when_visible(5) web_object.should === watir_definition end it "should wait for a web object to become invisible" do watir_browser.should_receive(:visible?).and_return(false) watir_definition.when_not_visible(5) end it "should reference a web object when it is not visible" do watir_browser.stub(:visible?).and_return(false) web_object = watir_definition.when_not_visible(5) web_object.should === watir_definition end it "should wait until a specific condition occurs" do Object::Watir::Wait.stub(:until).with(5, "Condition occurred.") watir_definition.wait_until(5, "Condition occurred.") { true } end end