Tests for clicking a button given the title.

This commit is contained in:
Javier Martín 2011-03-14 04:29:26 +01:00
parent 6f2e8c547b
commit cb4a93066b
2 changed files with 38 additions and 3 deletions

View File

@ -123,6 +123,18 @@ shared_examples_for "click_button" do
end
end
context "with title given on a submit button" do
it "should submit the associated form" do
@session.click_button('What an Awesome Button')
extract_results(@session)['first_name'].should == 'John'
end
it "should work with partial matches" do
@session.click_button('What an Awesome')
extract_results(@session)['first_name'].should == 'John'
end
end
context "with alt given on an image button" do
it "should submit the associated form" do
@session.click_button('oh hai thar')
@ -154,6 +166,18 @@ shared_examples_for "click_button" do
end
end
context "with title given on an image button" do
it "should submit the associated form" do
@session.click_button('Okay 556 Image')
extract_results(@session)['first_name'].should == 'John'
end
it "should work with partial matches" do
@session.click_button('Okay 556')
extract_results(@session)['first_name'].should == 'John'
end
end
context "with text given on a button defined by <button> tag" do
it "should submit the associated form" do
@session.click_button('Click me')
@ -203,6 +227,17 @@ shared_examples_for "click_button" do
end
end
context "with title given on a button defined by <button> tag" do
it "should submit the associated form" do
@session.click_button('Click Title button')
extract_results(@session)['first_name'].should == 'John'
end
it "should work with partial matches" do
@session.click_button('Click Title')
extract_results(@session)['first_name'].should == 'John'
end
end
context "with a locator that doesn't exist" do
it "should raise an error" do
running do

View File

@ -247,10 +247,10 @@
<p>
<input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
<input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
<input type="submit" name="form[awesome]" id="awe123" title="What an Awesome Button" value="awesome"/>
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
<input type="image" name="form[okay]" id="okay556" value="okay" alt="oh hai thar"/>
<button type="submit" id="click_me_123" value="click_me">Click me!</button>
<input type="image" name="form[okay]" id="okay556" title="Okay 556 Image" value="okay" alt="oh hai thar"/>
<button type="submit" id="click_me_123" title="Click Title button" value="click_me">Click me!</button>
<button type="submit" name="form[no_value]">No Value!</button>
<button id="no_type">No Type!</button>
</p>