From e479d90d4064869edd787c575095c3ceabd49dd0 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Fri, 16 Mar 2018 14:33:52 -0700 Subject: [PATCH] Require 'current_url' and 'title' to be for the top level browsing context - Issue #1845 --- lib/capybara/spec/session/current_url_spec.rb | 11 +++++++++++ lib/capybara/spec/session/title_spec.rb | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/capybara/spec/session/current_url_spec.rb b/lib/capybara/spec/session/current_url_spec.rb index bf5ff511..440ae8b3 100644 --- a/lib/capybara/spec/session/current_url_spec.rb +++ b/lib/capybara/spec/session/current_url_spec.rb @@ -105,4 +105,15 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do expect { @session.current_url }.not_to raise_exception expect { @session.current_path }.not_to raise_exception end + + context "within iframe", requires: [:frames] do + it "should get the url of the top level browsing context" do + @session.visit('/within_frames') + expect(@session.current_url).to match(/within_frames\z/) + @session.within_frame('frameOne') do + expect(@session.current_url).to match(/within_frames\z/) + end + end + end + end diff --git a/lib/capybara/spec/session/title_spec.rb b/lib/capybara/spec/session/title_spec.rb index 14cf1d9c..c3a1605e 100644 --- a/lib/capybara/spec/session/title_spec.rb +++ b/lib/capybara/spec/session/title_spec.rb @@ -14,4 +14,14 @@ Capybara::SpecHelper.spec '#title' do end after { Capybara.default_selector = :xpath } end + + context "within iframe", requires: [:frames] do + it "should get the title of the top level browsing context" do + @session.visit('/within_frames') + expect(@session.title).to eq('With Frames') + @session.within_frame('frameOne') do + expect(@session.title).to eq('With Frames') + end + end + end end