Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/capybara/cuprite/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ def switch_to_frame(locator)
handle = case locator
when Capybara::Node::Element
locator.native.description["frameId"]
when Capybara::Cuprite::Node
locator.description["frameId"]
Comment thread
myabc marked this conversation as resolved.
when :parent, :top
locator
end

raise ArgumentError, "Unable to switch to frame from #{locator.class}" unless handle

browser.switch_to_frame(handle)
end

Expand Down
21 changes: 21 additions & 0 deletions spec/features/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,27 @@
end
end

it "supports selection by driver node" do
@session.visit "/cuprite/frames"
frame = @session.driver.find_css("iframe[name]").first

@session.driver.switch_to_frame(frame)
expect(@session.driver.frame_url).to end_with("/cuprite/slow")
ensure
@session.driver.switch_to_frame(:top)
end

it "rejects driver nodes without frame ids" do
@session.visit "/cuprite/simple"
node = @session.driver.find_css("body").first

expect do
@session.driver.switch_to_frame(node)
end.to raise_error(ArgumentError, /Unable to switch to frame/)

expect(@session.driver.frame_url).to end_with("/cuprite/simple")
end

it "supports selection by element without name or id" do
@session.visit "/cuprite/frames"
frame = @session.find(:css, "iframe:not([name]):not([id])")
Expand Down
Loading