Skip to content

Commit

Permalink
Add switch_to.parent_frame support to Ruby bindings
Browse files Browse the repository at this point in the history
Signed-off-by: Jari Bakken <[email protected]>
  • Loading branch information
abotalov authored and jarib committed Jun 25, 2014
1 parent 039b6a4 commit 5b97733
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rb/lib/selenium/webdriver/common/target_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ def frame(id)
@bridge.switchToFrame id
end

#
# switch to the parent frame
#

def parent_frame
@bridge.switchToParentFrame
end

#
# switch to the given window handle
#
Expand Down
4 changes: 4 additions & 0 deletions rb/lib/selenium/webdriver/remote/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ def switchToFrame(id)
execute :switchToFrame, {}, :id => id
end

def switchToParentFrame
execute :switchToParentFrame
end

def switchToDefaultContent
execute :switchToFrame, {}, :id => nil
end
Expand Down
1 change: 1 addition & 0 deletions rb/lib/selenium/webdriver/remote/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Selenium::WebDriver::Remote::Bridge
#

command :switchToFrame, :post, "session/:session_id/frame"
command :switchToParentFrame, :post, "session/:session_id/frame/parent"
command :switchToWindow, :post, "session/:session_id/window"

#
Expand Down
12 changes: 12 additions & 0 deletions rb/spec/integration/selenium/webdriver/target_locator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
end
end

it "should switch to parent frame" do
driver.navigate.to url_for("iframes.html")

iframe = driver.find_element(:tag_name => "iframe")
driver.switch_to.frame(iframe)

driver.find_element(:name, 'login').should be_kind_of(WebDriver::Element)

driver.switch_to.parent_frame
driver.find_element(:id, 'iframe_page_heading').should be_kind_of(WebDriver::Element)
end

# switching by name not yet supported by safari
not_compliant_on :browser => [:ie, :iphone, :safari] do
it "should switch to a window and back when given a block" do
Expand Down

0 comments on commit 5b97733

Please sign in to comment.