mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Added support for input type="image"
This commit is contained in:
parent
8a39001a44
commit
b061056d1b
4 changed files with 26 additions and 4 deletions
|
@ -37,7 +37,7 @@ class Webcat::Driver::RackTest
|
||||||
def click
|
def click
|
||||||
if tag_name == 'a'
|
if tag_name == 'a'
|
||||||
session.visit(self[:href])
|
session.visit(self[:href])
|
||||||
elsif tag_name == 'input' and type == 'submit'
|
elsif tag_name == 'input' and %w(submit image).include?(type)
|
||||||
Form.new(session, form).submit(self)
|
Form.new(session, form).submit(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -68,7 +68,12 @@ private
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_button(locator)
|
def find_button(locator)
|
||||||
find_element("//input[@type='submit'][@id='#{locator}']", "//input[@type='submit'][@value='#{locator}']")
|
find_element(
|
||||||
|
"//input[@type='submit'][@id='#{locator}']",
|
||||||
|
"//input[@type='submit'][@value='#{locator}']",
|
||||||
|
"//input[@type='image'][@id='#{locator}']",
|
||||||
|
"//input[@type='image'][@value='#{locator}']"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_field(locator, *kinds)
|
def find_field(locator, *kinds)
|
||||||
|
|
|
@ -61,7 +61,7 @@ shared_examples_for "session" do
|
||||||
@session.visit('/form')
|
@session.visit('/form')
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with value given" do
|
context "with value given on a submit button" do
|
||||||
before do
|
before do
|
||||||
@session.click_button('awesome')
|
@session.click_button('awesome')
|
||||||
@results = YAML.load(@session.body)
|
@results = YAML.load(@session.body)
|
||||||
|
@ -118,7 +118,7 @@ shared_examples_for "session" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with id given" do
|
context "with id given on a submit button" do
|
||||||
it "should submit the associated form" do
|
it "should submit the associated form" do
|
||||||
@session.click_button('awe123')
|
@session.click_button('awe123')
|
||||||
results = YAML.load(@session.body)
|
results = YAML.load(@session.body)
|
||||||
|
@ -126,6 +126,22 @@ shared_examples_for "session" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with value given on an image button" do
|
||||||
|
it "should submit the associated form" do
|
||||||
|
@session.click_button('okay')
|
||||||
|
results = YAML.load(@session.body)
|
||||||
|
results['first_name'].should == 'John'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with id given on an image button" do
|
||||||
|
it "should submit the associated form" do
|
||||||
|
@session.click_button('okay556')
|
||||||
|
results = YAML.load(@session.body)
|
||||||
|
results['first_name'].should == 'John'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "should follow redirects" do
|
it "should follow redirects" do
|
||||||
@session.click_button('Go FAR')
|
@session.click_button('Go FAR')
|
||||||
@session.body.should include('You landed')
|
@session.body.should include('You landed')
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
|
<input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
|
||||||
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
|
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
|
||||||
|
<input type="image" name="form[okay]" id="okay556" value="okay"/>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue