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:
parent
d690c8815e
commit
c2034fd193
2 changed files with 10 additions and 2 deletions
|
@ -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
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue