Fix selenium issue with fieldset nested in disabled fieldset not being disabled
This commit is contained in:
parent
83172fddab
commit
06265cefd5
|
@ -74,6 +74,8 @@ Capybara.add_selector(:fieldset) do
|
||||||
xpath = xpath[XPath.child(:legend)[XPath.string.n.is(legend)]] if legend
|
xpath = xpath[XPath.child(:legend)[XPath.string.n.is(legend)]] if legend
|
||||||
xpath
|
xpath
|
||||||
end
|
end
|
||||||
|
|
||||||
|
node_filter(:disabled, :boolean) { |node, value| !(value ^ node.disabled?) }
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.add_selector(:link) do
|
Capybara.add_selector(:link) do
|
||||||
|
|
|
@ -142,8 +142,7 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
||||||
def disabled?
|
def disabled?
|
||||||
return true unless native.enabled?
|
return true unless native.enabled?
|
||||||
# WebDriver only defines `disabled?` for form controls but fieldset makes sense too
|
# WebDriver only defines `disabled?` for form controls but fieldset makes sense too
|
||||||
return boolean_attr(self[:disabled]) if tag_name == 'fieldset'
|
tag_name == 'fieldset' && find_xpath("ancestor-or-self::fieldset[@disabled]").any?
|
||||||
false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def content_editable?
|
def content_editable?
|
||||||
|
|
|
@ -13,8 +13,10 @@ class Capybara::Selenium::MarionetteNode < Capybara::Selenium::Node
|
||||||
end
|
end
|
||||||
|
|
||||||
def disabled?
|
def disabled?
|
||||||
return true if super
|
# Not sure exactly what version of FF fixed the below issue, but it is definitely fixed in 61+
|
||||||
|
return super unless driver.browser.capabilities[:browser_version].to_f < 61.0
|
||||||
|
|
||||||
|
return true if super
|
||||||
# workaround for selenium-webdriver/geckodriver reporting elements as enabled when they are nested in disabling elements
|
# workaround for selenium-webdriver/geckodriver reporting elements as enabled when they are nested in disabling elements
|
||||||
if %w[option optgroup].include? tag_name
|
if %w[option optgroup].include? tag_name
|
||||||
find_xpath("parent::*[self::optgroup or self::select]")[0].disabled?
|
find_xpath("parent::*[self::optgroup or self::select]")[0].disabled?
|
||||||
|
|
|
@ -208,6 +208,12 @@ Capybara::SpecHelper.spec "node" do
|
||||||
expect(@session.find('//select[@id="form_disabled_select2"]/option').disabled?).to be true
|
expect(@session.find('//select[@id="form_disabled_select2"]/option').disabled?).to be true
|
||||||
expect(@session.find('//select[@id="form_title"]/option[1]').disabled?).to be false
|
expect(@session.find('//select[@id="form_title"]/option[1]').disabled?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should be disabled for all elements that are CSS :disabled" do
|
||||||
|
@session.visit('/form')
|
||||||
|
# sanity check
|
||||||
|
expect(@session.all(:css, ':disabled')).to all(be_disabled)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#visible?" do
|
describe "#visible?" do
|
||||||
|
|
|
@ -370,7 +370,6 @@ New line after and before textarea tag
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label for="form_disabled_file">
|
<label for="form_disabled_file">
|
||||||
Disabled File
|
Disabled File
|
||||||
|
@ -378,14 +377,10 @@ New line after and before textarea tag
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<input name="form[enabled_fieldset_child]" id="form_enabled_fieldset_child"/>
|
<input name="form[enabled_fieldset_child]" id="form_enabled_fieldset_child"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<fieldset disabled="disabled" id="form_disabled_fieldset">
|
<fieldset disabled="disabled" id="form_disabled_fieldset">
|
||||||
<legend>Disabled Child</legend>
|
<legend>Disabled Child</legend>
|
||||||
<input name="form[disabled_fieldset_child]" id="form_disabled_fieldset_child"/>
|
<input name="form[disabled_fieldset_child]" id="form_disabled_fieldset_child"/>
|
||||||
|
@ -403,13 +398,14 @@ New line after and before textarea tag
|
||||||
Another Legend
|
Another Legend
|
||||||
<input type="checkbox" name="form[disabled_fieldeset_second_legend_child]" id="form_disabled_fieldset_second_legend_child"/>
|
<input type="checkbox" name="form[disabled_fieldeset_second_legend_child]" id="form_disabled_fieldset_second_legend_child"/>
|
||||||
</legend>
|
</legend>
|
||||||
<p>
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
Disabled?
|
||||||
|
<input id="form_disabled_fieldset_descendant_legend_child">
|
||||||
|
</legend>
|
||||||
<input name="form[disabled_fieldset_descendant]" id="form_disabled_fieldset_descendant"/>
|
<input name="form[disabled_fieldset_descendant]" id="form_disabled_fieldset_descendant"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</p>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<select>
|
<select>
|
||||||
|
@ -461,7 +457,7 @@ New line after and before textarea tag
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form id="form2" action="/form" method="post">
|
<form id="form2" action="/form" method="post">
|
||||||
<input type="text" name="form[which_form]" value="form2" id="form_which_form"/>
|
<input type="text" name="form[which_form]" value="form2" id="form_which_form2"/>
|
||||||
<input type="submit" name="form[unused]" value="unused"/>
|
<input type="submit" name="form[unused]" value="unused"/>
|
||||||
<button type="submit" name="form[other_form_button]" value="other_form_button" form="form1">Form1</button>
|
<button type="submit" name="form[other_form_button]" value="other_form_button" form="form1">Form1</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue