Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Selenium WebDriverException: "The browser appears to have exited"

I got this exception when I want to use FireFox webdriver

raise WebDriverException "The browser appears to have exited " 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.

I read this question and updated my selenium, but I already have the same problem.

my code :

driver = webdriver.Firefox()
time.sleep(5)
driver.get('http://www.example.com')

UPDATE

I read this question

and now I have this error

OSError: [Errno 20] Not a directory
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x407a690>> ignored
like image 695
parik Avatar asked Jun 28 '16 10:06

parik


4 Answers

If you're running Selenium on Firefox 47.0, you need to update to Firefox 47.0.1 which is not released in Ubuntu's main repos.. so you have to add this PPA: https://launchpad.net/~ubuntu-mozilla-security/+archive/ubuntu/ppa

Release notes: https://www.mozilla.org/en-US/firefox/47.0.1/releasenotes/

"Selenium WebDriver may cause Firefox to crash at startup"

Once Firefox 48.0 is out, it will include the fix. I think Ubuntu has skipped this update because it affects very few users.

I can confirm the error with FF 47.0 and Selenium 2.53, and I can also confirm that upgrading to FF 47.0.1 fixes the error.

like image 197
benjaoming Avatar answered Nov 15 '22 13:11

benjaoming


This is fixed by updating firefox 47.0.0 to 47.0.1 manually

like image 28
Mesut GUNES Avatar answered Nov 15 '22 13:11

Mesut GUNES


Just for people like me wasting hours with installing several firefox versions to make this working: same message error appears if you are running tests in an environment without display (e.g. SSH to your vagrant box).

sudo apt-get install xvfb

#set display number to :99
Xvfb :99 -ac &
export DISPLAY=:99

Remember to put this in a .bashrc because it's valid only in the current session shell.

From:

Is it possible to run selenium (Firefox) web driver without a GUI?

like image 27
BangTheBank Avatar answered Nov 15 '22 14:11

BangTheBank


I was having the same problem with my selenium script. I had to make sure that I was using the proper software versions as described in the selenium installation documentation, namely Pyhton 3.5 and Firefox version 45 (https://support.mozilla.org/en-US/kb/install-older-version-of-firefox). I am using the selenium version 2.9.1 although from reading around 2.53 may work best.

I noticed in the comments you also questioned how you can check the version of your Firefox. To do this you can go open a Firefox browser, click the menu button and click the question mark at the bottom of the pop-out menu, and finally click "About Firefox". The version number should be the second line of text in the pop-up. There may be other ways to do so but this worked for me.

Hopefully this will help you get your script to run.

like image 1
JoeDocei Hill Avatar answered Nov 15 '22 14:11

JoeDocei Hill