diff --git a/lib/capybara/selector.rb b/lib/capybara/selector.rb index f56fa532..1c572034 100644 --- a/lib/capybara/selector.rb +++ b/lib/capybara/selector.rb @@ -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 \ No newline at end of file diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index 9a5cbbd7..1f06d5d2 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -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