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
|
||||
if tag_name == 'a'
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,12 @@ private
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def find_field(locator, *kinds)
|
||||
|
|
|
@ -61,7 +61,7 @@ shared_examples_for "session" do
|
|||
@session.visit('/form')
|
||||
end
|
||||
|
||||
context "with value given" do
|
||||
context "with value given on a submit button" do
|
||||
before do
|
||||
@session.click_button('awesome')
|
||||
@results = YAML.load(@session.body)
|
||||
|
@ -118,7 +118,7 @@ shared_examples_for "session" do
|
|||
end
|
||||
end
|
||||
|
||||
context "with id given" do
|
||||
context "with id given on a submit button" do
|
||||
it "should submit the associated form" do
|
||||
@session.click_button('awe123')
|
||||
results = YAML.load(@session.body)
|
||||
|
@ -126,6 +126,22 @@ shared_examples_for "session" do
|
|||
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
|
||||
@session.click_button('Go FAR')
|
||||
@session.body.should include('You landed')
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
<p>
|
||||
<input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
|
||||
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
|
||||
<input type="image" name="form[okay]" id="okay556" value="okay"/>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Reference in a new issue