support form attribute for submit buttons
This commit is contained in:
parent
8368069cfd
commit
239c212714
|
@ -112,7 +112,11 @@ private
|
|||
end
|
||||
|
||||
def form
|
||||
native.ancestors('form').first
|
||||
if native[:form]
|
||||
native.xpath("//form[@id='#{native[:form]}']").first
|
||||
else
|
||||
native.ancestors('form').first
|
||||
end
|
||||
end
|
||||
|
||||
def set_radio(value)
|
||||
|
|
|
@ -137,7 +137,7 @@ Capybara::SpecHelper.spec '#click_button' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with id given on a submit button" do
|
||||
it "should submit the associated form" do
|
||||
@session.click_button('awe123')
|
||||
|
@ -161,7 +161,40 @@ Capybara::SpecHelper.spec '#click_button' do
|
|||
extract_results(@session)['first_name'].should == 'John'
|
||||
end
|
||||
end
|
||||
|
||||
context "with submit button outside the form defined by <button> tag" do
|
||||
before do
|
||||
@session.click_button('outside_button')
|
||||
@results = extract_results(@session)
|
||||
end
|
||||
|
||||
it "should submit the associated form" do
|
||||
@results['first_name'].should == 'John'
|
||||
end
|
||||
|
||||
it "should submit the button that was clicked, but not other buttons" do
|
||||
@results['outside_button'].should == 'outside_button'
|
||||
@results['crappy'].should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "with submit button outside the form defined by <input type='submit'> tag" do
|
||||
before do
|
||||
@session.click_button('outside_submit')
|
||||
@results = extract_results(@session)
|
||||
end
|
||||
|
||||
it "should submit the associated form" do
|
||||
@results['first_name'].should == 'John'
|
||||
end
|
||||
|
||||
it "should submit the button that was clicked, but not other buttons" do
|
||||
@results['outside_submit'].should == 'outside_submit'
|
||||
@results['crappy'].should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with alt given on an image button" do
|
||||
it "should submit the associated form" do
|
||||
@session.click_button('oh hai thar')
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<h1>Form</h1>
|
||||
|
||||
<form action="/form" method="post">
|
||||
<form id="the_form" action="/form" method="post">
|
||||
|
||||
<p>
|
||||
<label for="form_title">Title</label>
|
||||
|
@ -256,6 +256,8 @@
|
|||
<input type="button" disabled value="Disabled button"/>
|
||||
</p>
|
||||
</form>
|
||||
<input type="submit" name="form[outside_submit]" value="outside_submit" form="the_form"/>
|
||||
<button type="submit" name="form[outside_button]" value="outside_button" form="the_form">Outside!</button>
|
||||
|
||||
<form id="get-form" action="/form/get?foo=bar" method="get">
|
||||
<p>
|
||||
|
|
Loading…
Reference in New Issue