Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enabled options in disabled selects are disabled

This is the behavior of Selenium and has been standardized in Capybara.
  • Loading branch information...
commit f8731b692a030a8f83f0375ae7127f44c9a97ef4 1 parent 8be4f31
@mhoran authored
Showing with 12 additions and 1 deletion.
  1. +5 −1 lib/capybara/webkit/node.rb
  2. +7 −0 spec/driver_spec.rb
View
6 lib/capybara/webkit/node.rb
@@ -92,7 +92,11 @@ def checked?
end
def disabled?
- self['disabled']
+ if %w(option optgroup).include? tag_name
+ self['disabled'] || find_xpath("parent::*")[0].disabled?
+ else
+ self['disabled']
+ end
end
def path
View
7 spec/driver_spec.rb
@@ -780,6 +780,9 @@ def visit(url, driver=driver)
<option id="select-option-monkey">Monkey</option>
<option id="select-option-capybara" selected="selected">Capybara</option>
</select>
+ <select name="disabled" disabled="disabled">
+ <option id="select-option-disabled">Disabled</option>
+ </select>
<select name="toppings" multiple="multiple">
<optgroup label="Mediocre Toppings">
<option selected="selected" id="topping-apple">Apple</option>
@@ -988,6 +991,10 @@ def visit(url, driver=driver)
readonly_input.set('enabled')
readonly_input.value.should == 'readonly'
end
+
+ it "should see enabled options in disabled select as disabled" do
+ driver.find_css("#select-option-disabled").first.should be_disabled
+ end
end
context "dom events" do
Please sign in to comment.
Something went wrong with that request. Please try again.