1

I use rspec 3.9, capybara 3.16 and selenium-webdriver 3.141 with chrome 73 to test a large web application. I have a lot of feature specs and sooner or later chrome becomes unresponsive, I can see the window open but nothing happening. This happens in headless mode too. There's no pattern to this, it just happens at random.

Failure/Error: example.run Selenium::WebDriver::Error::WebDriverError: chrome not reachable (Session info: chrome=73.0.3683.86) (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 3.10.0-1062.12.1.el7.x86_64 x86_64) 

I'd like to do something like:

config.after(:each, type: :feature) do |example| if example.exception # restart chrome! end end 

In combination with rspec-repeat, this will try up to 3 times. But I'm not sure how to restart the browser.

Does anyone know how to do this?

2
  • Did you ever find a complete solution to restarting the browser? Commented May 29, 2024 at 14:02
  • Negative. I don't remember what the issue was exactly but it no longer happened once we started using chrome inside a docker container. Must have been one of those annoying glitches that are so hard to figure out. Commented Jun 28, 2024 at 19:37

1 Answer 1

1

You can quit the session with Capybara.current_session.quit. This will cause a new Chrome instance to be started on the next visit call. https://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Session:quit

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Thomas. With your help I am now restarting Chrome on example exceptions. My main issue persists though, you wouldn't happen to know how to restart chromedriver as well?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.