spec/page-object/accessors_spec.rb in page-object-0.0.2 vs spec/page-object/accessors_spec.rb in page-object-0.0.3
- old
+ new
@@ -10,10 +10,12 @@
radio_button(:first, :id => 'first_choice')
button(:click_me, :id => 'button_submit')
div(:message, :id => 'message_id')
table(:cart, :id => 'cart_id')
cell(:total, :id => 'total')
+ span(:alert, :id => 'alert_id')
+ image(:logo, :id => 'logo')
end
describe PageObject::Accessors do
let(:watir_browser) { mock_watir_browser }
let(:selenium_browser) { mock_selenium_browser }
@@ -364,10 +366,48 @@
end
end
end
+ describe "span accessors" do
+ context "when called on a page object" do
+ it "should generate accessor methods" do
+ watir_page_object.should respond_to(:alert)
+ watir_page_object.should respond_to(:alert_span)
+ end
+ end
+
+ context "watir implementation" do
+ it "should retrieve the text from a span" do
+ watir_browser.should_receive(:span).and_return(watir_browser)
+ watir_browser.should_receive(:text).and_return("Alert")
+ watir_page_object.alert.should == "Alert"
+ end
+
+ it "should retrieve the span element from the page" do
+ watir_browser.should_receive(:span).and_return(watir_browser)
+ element = watir_page_object.alert_span
+ element.should be_instance_of PageObject::Elements::Span
+ end
+ end
+
+ context "selenium implementation" do
+ it "should retrieve the text from a span" do
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
+ selenium_browser.should_receive(:text).and_return("Alert")
+ selenium_page_object.alert.should == "Alert"
+ end
+
+ it "should retrieve the span element from the page" do
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
+ element = selenium_page_object.alert_span
+ element.should be_instance_of PageObject::Elements::Span
+
+ end
+ end
+ end
+
describe "table accessors" do
context "when called on a page object" do
it "should generate accessor methods" do
watir_page_object.should respond_to(:cart_table)
end
@@ -416,9 +456,33 @@
context "selenium implementation" do
it "should retrieve the text from the cell" do
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
selenium_browser.should_receive(:text).and_return('celldata')
selenium_page_object.total.should == 'celldata'
+ end
+ end
+ end
+
+ describe "image accessors" do
+ context "when called on a page object" do
+ it "should generate accessor methods" do
+ watir_page_object.should respond_to(:logo_image)
+ end
+ end
+
+ context "watir implementation" do
+ it "should retrieve the image element from the page" do
+ watir_browser.should_receive(:image).and_return(watir_browser)
+ element = watir_page_object.logo_image
+ element.should be_instance_of PageObject::Elements::Image
+ end
+ end
+
+ context "selenium implementation" do
+ it "should retrieve the image element from the page" do
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
+ element = selenium_page_object.logo_image
+ element.should be_instance_of PageObject::Elements::Image
end
end
end
end