mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
operate with values before manipulating them
This commit is contained in:
parent
ec467af08d
commit
b21c92f4ed
1 changed files with 13 additions and 15 deletions
|
@ -9,26 +9,24 @@ Capybara.add_selector(:button, locator_type: [String, Symbol]) do
|
|||
|
||||
unless locator.nil?
|
||||
locator = locator.to_s
|
||||
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(: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]
|
||||
input_btn_xpath += XPath.descendant(:label)[XPath.string.n.is(locator)].descendant(input_btn_xpath)
|
||||
|
||||
btn_xpath = btn_xpath[locator_matchers |
|
||||
XPath.string.n.is(locator) |
|
||||
XPath.descendant(:img)[XPath.attr(:alt).is(locator)]]
|
||||
btn_xpath += XPath.descendant(:label)[XPath.string.n.is(locator)].descendant(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)
|
||||
|
||||
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]
|
||||
image_btn_xpath = image_btn_xpath[alt_matches] +
|
||||
XPath.descendant(:label)[XPath.string.n.is(locator)].descendant(image_btn_xpath)
|
||||
end
|
||||
|
||||
%i[value title type].inject(input_btn_xpath.union(btn_xpath).union(image_btn_xpath)) do |memo, ef|
|
||||
|
|
Loading…
Reference in a new issue