Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ignore disabled fields and buttons, closes #771

  • Loading branch information...
commit dd805d639b62a9bf12773f8e3b9df3c5e5dd8cc2 1 parent 9c0093a
Jonas Nicklas authored
2  History.txt
View
@@ -23,6 +23,8 @@
* `find` now raises an error if more than one element was found. Since `find` is
used by most actions, like `click_link` under the surface, this means that all
actions need to unambiguous in the future. [Jonas Nicklas]
+* All methods which find or manipulate fields or buttons now ignore them when
+ they are disabled. [Jonas Nicklas]
* `Element#text` on RackTest now only returns visible text and normalizes
(strips) whitespace, as with Selenium [Mark Dodwell, Jo Liss]
* `has_content?` now checks the text value returned by `Element#text`, as opposed to
8 lib/capybara/spec/session/check_spec.rb
View
@@ -74,4 +74,12 @@
end.should raise_error(Capybara::ElementNotFound, msg)
end
end
+
+ context "with a disabled checkbox" do
+ it "should raise an error" do
+ running do
+ @session.check('Disabled Checkbox')
+ end.should raise_error(Capybara::ElementNotFound)
+ end
+ end
end
8 lib/capybara/spec/session/choose_spec.rb
View
@@ -29,4 +29,12 @@
end.should raise_error(Capybara::ElementNotFound, msg)
end
end
+
+ context "with a disabled radio button" do
+ it "should raise an error" do
+ running do
+ @session.choose('Disabled Radio')
+ end.should raise_error(Capybara::ElementNotFound)
+ end
+ end
end
6 lib/capybara/spec/session/click_button_spec.rb
View
@@ -302,6 +302,12 @@
@session.should have_content('Postback')
end
+ it "ignores disabled buttons" do
+ expect do
+ @session.click_button('Disabled button')
+ end.to raise_error(Capybara::ElementNotFound)
+ end
+
it "should encode complex field names, like array[][value]" do
@session.visit('/form')
@session.fill_in('address1_city', :with =>'Paris')
8 lib/capybara/spec/session/fill_in_spec.rb
View
@@ -130,4 +130,12 @@
end.should raise_error(Capybara::ElementNotFound, msg)
end
end
+
+ context "on a disabled field" do
+ it "should raise an error" do
+ running do
+ @session.fill_in('Disabled Text Field', :with => 'Blah blah')
+ end.should raise_error(Capybara::ElementNotFound)
+ end
+ end
end
8 lib/capybara/spec/session/select_spec.rb
View
@@ -77,6 +77,14 @@
end
end
+ context "on a disabled select" do
+ it "should raise an error" do
+ running do
+ @session.select('Should not see me', :from => 'Disabled Select')
+ end.should raise_error(Capybara::ElementNotFound)
+ end
+ end
+
context "with multiple select" do
it "should return an empty value" do
@session.find_field('Language').value.should == []
1  lib/capybara/spec/views/form.erb
View
@@ -253,6 +253,7 @@
<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>
+ <input type="button" disabled value="Disabled button"/>
</p>
</form>
2  xpath
@@ -1 +1 @@
-Subproject commit 6873e1655e1945b624673956a0595e64b865d64a
+Subproject commit ee35f7b383f590680b55a191f89a31e9ae06c615
Please sign in to comment.
Something went wrong with that request. Please try again.