Forums

Selenium, recent increase of errors

Hello,

I've been recently experiencing a high number of:

selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

Selenium version is: 2.53.6 which I tried to re-install several times.

Firefox version is: 17.0

I've flushed the /tmp folder.

What do you recommend for a smooth run, taking in consideration that one script run about every 20 minutes?

Thanks

The most likely causes of that are:

  1. You're leaving Firefox instances lying around and not closing them, so you can't start new processes
  2. You're using up your CPU allowance and so the browser is taking too long to start up and selenium is timing out

Thanks for your answer.

One fix is to re-install Selenium

pip install "selenium<3" --user

It's been challenging me since the command was not re-installing selenium. The key is to create a virtual environment and then install selenium.

virtualenv env_name

source env_name/bin/activate

I should have done this at the first place, but things were doing alright without virtual environment.

We do recommend sticking with the versions of Selenium that we have installed -- there are a few problems with recent Firefox versions on PythonAnywhere (more recent ones have dependencies of OS features that aren't available in our virtualization system), and more recent versions of Selenium depend on those recent Firefox versions.

OTOH if you have something that's working, then that's great :-) Just make sure you're always quitting the browser object when you're done with it, even if there are exceptions, as otherwise you can wind up with processes piling up and causing you to run out of resources.