mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
fix rubocop violations
This commit is contained in:
parent
b21c92f4ed
commit
1a8baa72a0
2 changed files with 18 additions and 14 deletions
|
@ -9,24 +9,24 @@ Capybara.add_selector(:button, locator_type: [String, Symbol]) do
|
|||
|
||||
unless locator.nil?
|
||||
locator = locator.to_s
|
||||
attr_matchers = XPath.attr(:id).equals(locator) |
|
||||
locator_matchers = XPath.attr(:id).equals(locator) |
|
||||
XPath.attr(:name).equals(locator) |
|
||||
XPath.attr(:value).is(locator) |
|
||||
XPath.attr(:title).is(locator) |
|
||||
(XPath.attr(:id) == XPath.anywhere(:label)[XPath.string.n.is(locator)].attr(:for))
|
||||
attr_matchers |= XPath.attr(:'aria-label').is(locator) if enable_aria_label
|
||||
attr_matchers |= XPath.attr(test_id) == locator if test_id
|
||||
locator_matchers |= XPath.attr(:'aria-label').is(locator) if enable_aria_label
|
||||
locator_matchers |= XPath.attr(test_id) == locator if test_id
|
||||
|
||||
input_btn_xpath = input_btn_xpath[attr_matchers] +
|
||||
XPath.descendant(:label)[XPath.string.n.is(locator)].descendant(input_btn_xpath)
|
||||
input_btn_xpath = input_btn_xpath[locator_matchers] + locate_label(locator).descendant(input_btn_xpath)
|
||||
|
||||
btn_xpath = btn_xpath[attr_matchers | XPath.string.n.is(locator) | XPath.descendant(:img)[XPath.attr(:alt).is(locator)]] +
|
||||
XPath.descendant(:label)[XPath.string.n.is(locator)].descendant(btn_xpath)
|
||||
btn_xpath = btn_xpath[locator_matchers |
|
||||
XPath.string.n.is(locator) |
|
||||
XPath.descendant(:img)[XPath.attr(:alt).is(locator)]
|
||||
] + locate_label(locator).descendant(btn_xpath)
|
||||
|
||||
alt_matches = XPath.attr(:alt).is(locator)
|
||||
alt_matches |= XPath.attr(:'aria-label').is(locator) if enable_aria_label
|
||||
image_btn_xpath = image_btn_xpath[alt_matches] +
|
||||
XPath.descendant(:label)[XPath.string.n.is(locator)].descendant(image_btn_xpath)
|
||||
image_btn_xpath = image_btn_xpath[alt_matches] + locate_label(locator).descendant(image_btn_xpath)
|
||||
end
|
||||
|
||||
%i[value title type].inject(input_btn_xpath.union(btn_xpath).union(image_btn_xpath)) do |memo, ef|
|
||||
|
|
|
@ -132,7 +132,11 @@ module Capybara
|
|||
attr_matchers |= XPath.attr(test_id) == locator if test_id
|
||||
|
||||
locate_xpath = locate_xpath[attr_matchers]
|
||||
locate_xpath + XPath.descendant(:label)[XPath.string.n.is(locator)].descendant(xpath)
|
||||
locate_xpath + locate_label(locator).descendant(xpath)
|
||||
end
|
||||
|
||||
def locate_label(locator)
|
||||
XPath.descendant(:label)[XPath.string.n.is(locator)]
|
||||
end
|
||||
|
||||
def find_by_attr(attribute, value)
|
||||
|
|
Loading…
Reference in a new issue