Skip to content

Commit 5b97733

Browse files
abotalovjarib
authored andcommitted
Add switch_to.parent_frame support to Ruby bindings
Signed-off-by: Jari Bakken <[email protected]>
1 parent 039b6a4 commit 5b97733

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

rb/lib/selenium/webdriver/common/target_locator.rb

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ def frame(id)
1818
@bridge.switchToFrame id
1919
end
2020

21+
#
22+
# switch to the parent frame
23+
#
24+
25+
def parent_frame
26+
@bridge.switchToParentFrame
27+
end
28+
2129
#
2230
# switch to the given window handle
2331
#

rb/lib/selenium/webdriver/remote/bridge.rb

+4
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ def switchToFrame(id)
190190
execute :switchToFrame, {}, :id => id
191191
end
192192

193+
def switchToParentFrame
194+
execute :switchToParentFrame
195+
end
196+
193197
def switchToDefaultContent
194198
execute :switchToFrame, {}, :id => nil
195199
end

rb/lib/selenium/webdriver/remote/commands.rb

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Selenium::WebDriver::Remote::Bridge
6565
#
6666

6767
command :switchToFrame, :post, "session/:session_id/frame"
68+
command :switchToParentFrame, :post, "session/:session_id/frame/parent"
6869
command :switchToWindow, :post, "session/:session_id/window"
6970

7071
#

rb/spec/integration/selenium/webdriver/target_locator_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
end
2727
end
2828

29+
it "should switch to parent frame" do
30+
driver.navigate.to url_for("iframes.html")
31+
32+
iframe = driver.find_element(:tag_name => "iframe")
33+
driver.switch_to.frame(iframe)
34+
35+
driver.find_element(:name, 'login').should be_kind_of(WebDriver::Element)
36+
37+
driver.switch_to.parent_frame
38+
driver.find_element(:id, 'iframe_page_heading').should be_kind_of(WebDriver::Element)
39+
end
40+
2941
# switching by name not yet supported by safari
3042
not_compliant_on :browser => [:ie, :iphone, :safari] do
3143
it "should switch to a window and back when given a block" do

0 commit comments

Comments
 (0)