-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Consecutive specs using selenium hangs #1035
Comments
Capybara resets sessions in After hook: It's done to ensure that state isn't shared between specs/scenarios |
Hi @abotalov - this sounds like it could be related Currently at the top of acceptance_helper.rb I already have: require "spec_helper" Not sure what I need to do to fix it? Any help would be appreciated. |
This behavior (not preserving state from previous specs/scenarios) is intentional as it's considered a good practice to have all scenarios independent from each other. I know a man that "fixes" that by using a fork of Capybara with rows I linked to removed |
Ah right I'm referring to a different issue - when running consecutive specs using the selenium driver using a command such as: rspec spec/acceptance/some_dir/** will open chrome, run the first spec, then the second spec will start and it will hang with a blank page in chrome. The URL will say something like 'http://127.0.0.1:8973' or some port and chrome will just have a 'loading' status and hang. If I open another chrome browser and paste in the same URL it works fine. Hope that makes sense and describes the problem better? |
After 120 secs the spec will fail with 'Timeout::Error' |
We're having the same issues. Sometimes when a new feature starts chrome just opens up, the URL is there, but the loader jsut keeps spinning without any response, or page loading. |
I never figured out what the problem was, and I had to switch to webkit instead which was a bit annoying. @sztupy if you do figure it out please do let me know thanks |
What operating system and version you're using? |
OS X Mountain lion |
Thought so. We didn't have problems on either Linux or OS X Lion. |
Just replaced chromedriver with the new chromedriver2, and modified selenium-webdriver to work with it, and I didn't had any issues since that. I uploaded the modified chromedriver-helper and selenium-webdriver gems to github: https://github.com/sztupy/chromedriver-helper only tested on OS X 10.8.3 |
We're having this same issue on OS X 10.8.4. We were using an old version of chromedriver (pre 2.0) and I upgraded it to 2.1 which at first seemed to fix this issue. But a couple days later we still got test failures of this nature, but they're intermittent. They do seem to be much more rare now, but there still seems to be something wrong and it's very hard to debug. I'm not sure this is a Capybara bug. I'm guessing it's more likely a selenium-webdriver, Chrome, or chromedriver bug. |
You will still have the issue that you cannot (easily) set preferences (which were profiles in the previous version). Raised a bug with the webdriver guys: https://code.google.com/p/selenium/issues/detail?id=5951 Chromedriver-helper will work on linux, but not on mac or windows, as the platform's name was changed in the downloads. I uploaded chromedriver2-helper to rubygems, as it seems the original one is not updated. And yeah, some of the bugs came back unfortunately, but it's still more stable than it was with the old chromedriver. If things worsen again I'll try to find the actual cause of the issue. |
I am running into issues with Chrome hanging randomly with Chrome=28.0.1500.95 chromedriver=2.2,platform=Mac OS X 10.8 . Gems selenium-webdriver (2.34.0), capybara (~> 2.1.0) I've been looking at the chromedriver logs and I've noticed it seems to often follow a delete session cookie request that may be related to the session_reset that happens automatically between tests. Similar to @wakiki, I visually observe the browser just spinning on a blank page, but if I try manually navigating in a new tab in the same Chrome session with the Capy root URL (for example http://127.0.0.1:64579/ ) the expected page renders quickly. Exact same tests execute with no timeout errors in Firefox, and headless with phantomjs/poltergeist. I think it's probably an issue with the chromedriver and its interaction with Capy/selenium-webdriver, so this issue may belong in the chromedriver world. My chrome driver registration
example chromedriver log during a timeout
|
I did some more research into this issue and I'm pretty convinced it's a Chrome/ChromeDriver issue. May be this same issue open on the chromedriver project: https://code.google.com/p/chromedriver/issues/detail?id=252. I get very similar output to @gigiJackson in my chromedriver output. One thing that's different for me though, I can only reproduce this issue semi-consistently when navigating to about:blank, which Capybara does from the |
I can reproduce this very consistently with the following steps. I'm curious if it's not just me. First start up a rails console. Then run this setup line: This is with Chrome version 28.0.1500.95 and chromedriver 2.1. Interestingly enough, if I run: Again this seems like a Chrome/chromedriver bug, but like I mentioned in my last comment a workaround is to not let Capybara run
I realize this is super hacky, and it might not work for everyone if you're relying on cookies getting cleared or it navigating to about:blank in between tests. I'll continue to investigate this when I have more time. Any other help would be greatly appreciated. |
Yeah I get Net::ReadTimeout errors with chromedriver v2.2 and Chrome 29. It wont fail all of the time, but it rarely manages to get past two scenarios inside a cucumber feature. lyahdav's hacky solution works for me, and will be what I use for the moment. |
For what it's worth, I filed a bug on this : https://code.google.com/p/chromedriver/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Pri%20Owner%20Summary&groupby=&sort=-id&id=502 I can reproduce it without Capybara : require 'rack/handler/webrick'
require 'selenium-webdriver'
require 'rack'
class Selenium::WebDriver::Chrome::Bridge
def extract_service_args(args)
["--log-path=chromedriver.log", "--verbose"]
end
end
Thread.new{
app = proc { |env| [200, {}, ["Hello Server! #{env['PATH_INFO']}"]]}
Rack::Handler::WEBrick.run(app, :Port => 22790)
}
# Make sure the server has started
loop do
begin
break if Net::HTTP.start('127.0.0.1', 22790) { |http| http.get('/') }.is_a?(Net::HTTPSuccess)
rescue SystemCallError
sleep 0.01
end
end
loop do
browser = Selenium::WebDriver.for(:chrome)
puts Time.now
browser.navigate.to "http://127.0.0.1:22790/1"
browser.navigate.to('about:blank')
browser.quit
end ... that said, it does seem to be Capybara's navigating to about:blank that triggers the bug - I don't think I've seen it occur on visiting a regular page. Weird. |
I was banging my head against the monitor with this issue yesterday. Finally I found a workaround fix by observing the chromedriver logs showing that the network call to tell chromedriver to navigate to "about:blank" was never returning. (My google-fu was weak yesterday, only found this thread today.) I patched the reset method (https://github.com/jnicklas/capybara/blob/master/lib/capybara/selenium/driver.rb#L90) to navigate to 'about:help' instead and all works. I also noticed that the HEAD shutdown command was being ignored by chromedriver yesterday and I was accumulating Chrome instances, but this morning its working again. Its raining outside today, maybe that's the difference? I'll try chromedriver2 today if I can muster the will... Oh yeah and if anyone else has as much difficulty enabling chromedriver logging as I did (trawling through the selenium source code finally to find out how), here you go: Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome, :service_log_path => 'chromedriver.log')
end This is the only config you can pass to chromedriver as it stands (see https://code.google.com/p/selenium/source/browse/rb/lib/selenium/webdriver/chrome/bridge.rb#105) 😿 This was 100% consistently failing on: Cheers |
Also reproduced same behavior: The |
I was able to reproduce the issue was well: The about:help hack fixed the issue. |
For those of you having problems with this, could you try creating an empty file, and then trying to navigate to |
@jnicklas yes, that works, as does using a filename that doesn't exist. |
@jnicklas navigating to a file worked for me as well, and as brettporter noted, as does navigating to a file that does not exist. |
@jnicklas I just updated chromedriver to 2.4 (with Chrome 30.0) and the problem seems to have gone away, as did a problem I was having with a click event. The release notes indicate it supports Chrome 29.0 - 32.0, so perhaps the problem highlighted by recent commenters was chromedriver 2.3 + Chrome 29.0+? Incidentally, I noted that chromedriver starts on the URL |
Just pushed a fix for this, please give it a try, especially if any of you are on Windows. |
Hi @jnicklas! I noticed that 6b1e42d hard codes a local file system path. In my test suite, rspec/capybara/webdriver are running in a virtualbox, and only firefox and selenium are running on the local Mac. As a result, I see firefox's file not found error in between each test. Do you have any suggestions for working around this issue? |
Yeah, this solution has turned out to be problematic. I'll work on pushing a fix for it ASAP. If anyone has a suggestion on how to do this better, I'd love to hear it. |
@jnicklas how about |
In the server middleware, you have a special path '/identity' to check for the responsiveness of the server. |
It seems that #1214, #1203, and #1198, are all related to this. I'll try to fix this using the |
What's visiting the empty page trying to achieve? What about just deleting the code that does so? |
Hi Jonas I have a Windows VM I can test this on. Let me know when the patch is ready. Would you like me to test with a particular version of selenium/ chrome/ chromedriver? Cheers |
@jdelStrother there are multiple reasons for doing this, for one, it cancels all active Ajax requests, which prevents a lot of ugly race conditions on cleanup. Also, it prevents state from bleeding over between test cases, which is generally what you want. |
Hmm, unfortunately I'm getting errors between each test now. With the local file solution I was also getting errors when running IE tests remotely on Windows 7 from my mac :( Rolling back to the about:help still works for me on IE. Below is the selenium error message. As you can see its a remote test i'm running.
|
Damnit. |
Reading the comment from @brettporter above, I went back and tested the original implementation (using about:blank) and can confirm that with the latest chrome (31.0.1650.63)/ chromedriver (homebrew installed v2.7.236836)/ osx (10.9.1), about:blank no longer hangs between tests. So you might be able to roll back and forget about this whole frustrating episode? |
Okay, let's go for it. |
I've pushed 2.2.1 with this fix to Rubygems, let me know if anyone has further problems with this. |
🌵 Thanks @jnicklas! We'll try this out and will let you know if there are any problems. |
Tested on a setup with the original problem (running local tests with Chrome on OSX) and on a setup that didn't like the above fix (remote tests with IE on Windows 7 VM). Can confirm all is hunky dory now, thanks v much for the great project @jnicklas! |
I confirm there is a problem with Timeout::Error on IE+Win7, visit and click methods, browser hangs and fails with Timeout::Error. |
The issue seems to be reproducible again on Ubuntu with:
Issues is related to https://code.google.com/p/chromedriver/issues/detail?id=700, |
FWIW, the chrome/chromedriver bug appears to be fixed now - https://code.google.com/p/chromedriver/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Pri%20Owner%20Summary&groupby=&sort=&id=502. Not sure if we want to revert back to just using |
Another strange issue - running consecutive specs using selenium driver hangs (as in the browser window remains open, but it does not load the page). Changing to webkit driver works fine, and running individual specs using selenium works fine. Something is stopping consecutive specs running in selenium - has anyone come across this?
The text was updated successfully, but these errors were encountered: