Permalink
Browse files

Merge with jnicklas/master

  • Loading branch information...
2 parents 896849e + eb9f552 commit 0e0ef92bc646e1268f982c49085d577a4eda2c1c @aslakhellesoy committed Feb 25, 2010
View
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jonas Nicklas"]
- s.date = %q{2010-02-24}
+ s.date = %q{2010-02-25}
s.description = %q{Capybara aims to simplify the process of integration testing Rack applications,
such as Rails, Sinatra or Merb. It is inspired by and aims to replace Webrat as
a DSL for interacting with a webapplication. It is agnostic about the driver
@@ -19,7 +19,7 @@ Celerity and Selenium support built in.}
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{capybara}
- s.rubygems_version = %q{1.3.6}
+ s.rubygems_version = %q{1.3.5}
s.summary = %q{Capybara aims to simplify the process of integration testing Rack applications, such as Rails, Sinatra or Merb}
if s.respond_to? :specification_version then
@@ -14,7 +14,7 @@ def [](name)
end
def value
- if node.type == 'select-multiple'
+ if tag_name == "select" and node.multiple?
node.selected_options
else
super
@@ -16,6 +16,14 @@ def [](name)
nil
end
+ def value
+ if tag_name == "select" and self[:multiple]
+ node.find_elements(:xpath, ".//option").select { |n| n.selected? }.map { |n| n.text }
+ else
+ super
+ end
+ end
+
def set(value)
if tag_name == 'textarea' or (tag_name == 'input' and %w(text password hidden file).include?(type))
node.clear
View
@@ -9,7 +9,8 @@ class Session
:field_labeled, :fill_in, :find, :find_button, :find_by_id, :find_field, :find_link, :has_content?, :has_css?,
:has_no_content?, :has_no_css?, :has_no_xpath?, :has_xpath?, :locate, :save_and_open_page, :select, :source, :uncheck,
:visit, :wait_until, :within, :within_fieldset, :within_table, :has_link?, :has_no_link?, :has_button?, :has_no_button?,
- :has_field?, :has_no_field?, :has_checked_field?, :has_unchecked_field?
+ :has_field?, :has_no_field?, :has_checked_field?, :has_unchecked_field?, :has_no_table?, :has_table?, :unselect,
+ :has_select?, :has_no_select?
]
attr_reader :mode, :app
View
@@ -80,6 +80,7 @@ def button(locator)
xpath = append("//input[@type='submit' or @type='image' or @type='button'][@id=#{s(locator)} or contains(@value,#{s(locator)})]")
xpath = xpath.append("//button[@id=#{s(locator)} or contains(@value,#{s(locator)}) or contains(.,#{s(locator)})]")
xpath = xpath.prepend("//input[@type='submit' or @type='image' or @type='button'][@value=#{s(locator)}]")
+ xpath = xpath.prepend("//input[@type='image'][@alt=#{s(locator)} or contains(@alt,#{s(locator)})]")
xpath = xpath.prepend("//button[@value=#{s(locator)} or text()=#{s(locator)}]")
end
View
@@ -115,7 +115,7 @@
end
it "should be able to navigate/search child nodes" do
- @node.all('//table').size.should == 3
+ @node.all('//table').size.should == 5
@node.find('//form').all('//table').size.should == 1
@node.find('//form').find('//table//caption').text.should == 'Agent'
end
@@ -113,6 +113,18 @@
@session.body.should include('You landed')
end
end
+
+ context "with alt given on an image button" do
+ it "should submit the associated form" do
+ @session.click_button('oh hai thar')
+ extract_results(@session)['first_name'].should == 'John'
+ end
+
+ it "should work with partial matches" do
+ @session.click_button('hai')
+ extract_results(@session)['first_name'].should == 'John'
+ end
+ end
context "with value given on an image button" do
it "should submit the associated form" do
View
@@ -151,7 +151,7 @@
<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[crappy]" id="crap321" value="crappy"/>
- <input type="image" name="form[okay]" id="okay556" value="okay"/>
+ <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>
</p>
</form>

0 comments on commit 0e0ef92

Please sign in to comment.