Skip to content

Commit

Permalink
Navigate to about:blank to reset page instead of empty file
Browse files Browse the repository at this point in the history
closes #1035
closes #1214
closes #1203
closes #1198
closes #1215

Since it does not work with remote drivers, and somehow screws up on Windows.
  • Loading branch information
jnicklas committed Jan 6, 2014
1 parent f18637b commit 03ec848
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 20 deletions.
2 changes: 0 additions & 2 deletions lib/capybara.rb
Expand Up @@ -14,8 +14,6 @@ class UnselectNotAllowed < CapybaraError; end
class NotSupportedByDriverError < CapybaraError; end
class InfiniteRedirectError < CapybaraError; end

EMPTY_HTML_FILE_PATH = File.expand_path('./capybara/empty.html', File.dirname(__FILE__))

class << self
attr_accessor :asset_host, :app_host, :run_server, :default_host, :always_include_port
attr_accessor :server_port, :exact, :match, :exact_options, :visible_text_only
Expand Down
4 changes: 0 additions & 4 deletions lib/capybara/empty.html

This file was deleted.

4 changes: 1 addition & 3 deletions lib/capybara/selenium/driver.rb
Expand Up @@ -97,9 +97,7 @@ def reset!
# to about:blank, so we rescue this error and do nothing
# instead.
end
uri = URI(Capybara::EMPTY_HTML_FILE_PATH)
uri.scheme = "file"
@browser.navigate.to(uri.to_s)
@browser.navigate.to("about:blank")

This comment has been minimized.

Copy link
@JimiJonJimbo

JimiJonJimbo Feb 7, 2014

With ChromeDriver 2.9 on OS X 10.9.1, elements on pages are unable to receive focus after the browser navigates to about:blank.

This comment has been minimized.

Copy link
@jnicklas

jnicklas Feb 7, 2014

Author Collaborator

As in, it never fixes itself, even when going to a normal page afterwards? That sounds like a bug in chromedriver in that case, IMO.

This comment has been minimized.

Copy link
@JimiJonJimbo

JimiJonJimbo Feb 7, 2014

Ok, I've submitted a chromedriver issue: https://code.google.com/p/chromedriver/issues/detail?id=700

end
end

Expand Down
13 changes: 2 additions & 11 deletions lib/capybara/spec/session/reset_session_spec.rb
Expand Up @@ -16,17 +16,8 @@
@session.current_path.should == '/foo'

@session.reset_session!
[
->(v) { v == nil },
->(v) { v == '' },
->(v) { v == 'about:blank' },
->(v) { v.end_with? Capybara::EMPTY_HTML_FILE_PATH } # allow file:// protocol
].any? { |p| p.(@session.current_url) }.should be_true
[
->(v) { v == '' },
->(v) { v == nil },
->(v) { v == Capybara::EMPTY_HTML_FILE_PATH }
].any? { |p| p.(@session.current_path) }.should be_true
[nil, '', 'about:blank'].should include(@session.current_url)
['', nil].should include(@session.current_path)
@session.current_host.should be_nil
end

Expand Down

0 comments on commit 03ec848

Please sign in to comment.