1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Make frame finder a selector

This commit is contained in:
Thomas Walpole 2016-07-18 13:17:22 -07:00
parent d690c8815e
commit c2034fd193
2 changed files with 10 additions and 2 deletions

View file

@ -381,3 +381,11 @@ Capybara.add_selector(:table) do
xpath xpath
end end
end end
Capybara.add_selector(:frame) do
xpath do |locator|
xpath = XPath.descendant(:iframe)
xpath = xpath[XPath.attr(:id).equals(locator.to_s) | XPath.attr(:name).equals(locator)] unless locator.nil?
xpath
end
end

View file

@ -345,9 +345,9 @@ module Capybara
when Capybara::Node::Element when Capybara::Node::Element
locator locator
when String when String
find(:xpath, XPath.descendant(:iframe)[XPath.attr(:id).equals(locator) | XPath.attr(:name).equals(locator)].to_xpath(:exact)) find(:frame, locator)
when Integer when Integer
all(:css, 'iframe', minimum: locator+1)[locator] all(:frame, minimum: locator+1)[locator]
else else
raise ArgumentError raise ArgumentError
end end