Permalink
Browse files

Enabled options in disabled selects are disabled

This is the behavior of Selenium and has been standardized in Capybara.
  • Loading branch information...
1 parent 8be4f31 commit f8731b692a030a8f83f0375ae7127f44c9a97ef4 @mhoran committed Mar 21, 2013
Showing with 12 additions and 1 deletion.
  1. +5 −1 lib/capybara/webkit/node.rb
  2. +7 −0 spec/driver_spec.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
@@ -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

0 comments on commit f8731b6

Please sign in to comment.