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
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
locator
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
all(:css, 'iframe', minimum: locator+1)[locator]
all(:frame, minimum: locator+1)[locator]
else
raise ArgumentError
end