Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected not to find xpath "/html/body/*" #1198

Closed
benjamine opened this issue Nov 26, 2013 · 9 comments
Closed

Expected not to find xpath "/html/body/*" #1198

benjamine opened this issue Nov 26, 2013 · 9 comments

Comments

@benjamine
Copy link

I'm getting errors after every scenario after upgrading to 2.2.0, the problem is this assertion is failing:
https://github.com/jnicklas/capybara/blob/master/lib/capybara/session.rb#L81

expected not to find xpath "/html/body/*", found ...

tested using last versions of chrome and FF, with selenium driver on Windows.
I'm not sure, but it seems the reason is the browser is not navigating to a blank page, as supposed to.

(tests work fine using 2.1.0)

@twalpole
Copy link
Member

Navigating to about:blank was causing hangs when using chromedriver with selenium, so in 2.2 it changed to loading an empty html document - 6b1e42d - Do you happen to be using a remote browser that can't access the file?

@jnicklas
Copy link
Collaborator

Which driver are you using? It's possible some of them haven't caught up with the 2.2.0 changes yet. We now require reset to be synchronous, because otherwise it can cause strange failures, but it might not be in all drivers yet.

It's pretty bad that this breaks the driver API. Maybe this assertion should be removed. Pulling in @mhoran, @jferris @jcoglan and @jonleighton.

@mhoran
Copy link
Contributor

mhoran commented Nov 26, 2013

Reset is synchronous in capybara-webkit. All WebPage instances are destroyed, local storage is deleted, and the cookie store is emptied.

@benjamine
Copy link
Author

I'm using selenium webdriver, and yes I notice the browser is not navigating to a blank page.
The assertion error messages shows that the page content is still the content of the last page in the scenario.

These are the drivers I tested this with (both failing in the same assertion):

Capybara.register_driver :chrome do |app|
  caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => [ "start-maximized" ]})
  Capybara::Selenium::Driver.new(app, {:browser => :chrome, :desired_capabilities => caps})
end

Capybara.register_driver :firefox do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile.assume_untrusted_certificate_issuer = false
  profile.native_events = false
  Capybara::Selenium::Driver.new(app, :profile => profile)
end

@mhoran
Copy link
Contributor

mhoran commented Nov 26, 2013

capybara-webkit destroys all WebPage instances and then instantiates a new WebPage object but does not navigate to about:blank. This looks to be consistent with Selenium. Prior to capybara-webkit 0.14.0 we navigated to about:blank on reset (thoughtbot/capybara-webkit@1264113).

@benjamine
Copy link
Author

ok, but notice I'm not using capybara-webkit, but selenium webdriver, maybe could we have a config setting to turn that off for a specific driver?

@janv
Copy link

janv commented Dec 18, 2013

There is an additional problem with the behavior in 2.2.0:
Capybara navigates to a file on the local file system, then expects it to be empty.
This will fail if you use Capybara with Browsers that are not running on the same machine (in our case we use Sauce Labs). Navigating to the missing file results in Chrome displaying an error page and the assertion not to find /html/body/* fails because the error page actually contains HTML.

ghost pushed a commit that referenced this issue Dec 20, 2013
closes #1035
closes #1214
closes #1203
closes #1198

Since it does not work with remote drivers, and somehow screws up on Windows.
@jcoglan
Copy link
Contributor

jcoglan commented Dec 23, 2013

For what it's worth: in Terminus, I cheat a little bit by disabling find after a reset, and enabling it again on the next visit. See @find_enabled in https://github.com/jcoglan/terminus/blob/master/lib/terminus/browser.rb.

Navigating to about:blank would be problematic; since Terminus has to access everything via a proxy in order to inject the JavaScript driver, so the response necessarily contains HTML.

jnicklas added a commit that referenced this issue Jan 6, 2014
closes #1035
closes #1214
closes #1203
closes #1198
closes #1215

Since it does not work with remote drivers, and somehow screws up on Windows.
@benjamine
Copy link
Author

awesome, thanks

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants