Forums

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

.

    display = Display(visible=0, size=(800, 600))
    display.start()
    browser = webdriver.Firefox()
    browser.get('https://www.bing.com')
    browser.quit()
    display.stop()

[edit by admin: formatting]

If you use that kind of code, if an exception is raised inside the browser.get call, your display and your Firefox instance won't be called, so you'll wind up accumulating running processes that you can't connect to. Once enough have built up, you'll run out of system resources and won't be able to start new ones, which will give the error you're seeing.

Are you running this code from a scheduled task, or from a console? If so, go to the "Tasks" or "Consoles" tab as appropriate, then use the process list at the bottom of the page to kill rogue Firefox and Xvfb processes until you have none left. Then you can use the safer code from our Selenium help page, which clears up after itself if there is an error.

(If you're getting the problem in a web app, you won't be able to clear up rogue processes yourself -- let us know here on the forums if that's the case, and we'll do it for you.)

I am using the above code in webapp. I have changed my code to below

    browser = webdriver.Firefox()
    try:
        display = Display(visible=0, size=(800, 600))
        display.start()
        browser.get("http://www.pythonanywhere.com")
    finally:
        browser.quit()
        display.stop()

OK -- I've made sure that there are no rogue processes running on the webserver where your webapp runs. Could you try reloading your web app from the "Web" tab and see if you still get the same error?

Still the same.

Are you using the system-wide install of selenium? Or have you upgraded it or put it in a virtualenv? You need to use version 2.53.6 on PythonAnywhere.

I am using selenium 2.53.6

Have you installed a different version of Firefox, or something like that?

I havent installed firefox in pythonanywhere

This is really odd. What happens if you run the exact code you posted above in a console?

it says "No Module named pyvirtualdisplay". where exactly I have to install pyvirtualdisplay?

Are you using the virtualenv that your web app uses? From a console, you need to activate the virtualenv before running code that uses packages installed into it.

I activated my virtualenv and It is running without any error in console

Can I take a look at your code? We can see it from our admin interface, but we always ask for permission first.

Sure!! filename is views.py and it is under instagramAPI folder

Thanks! You can simplify the code you have there -- you don't need these two lines

        display = Display(visible=0, size=(800, 600))
        display.start()

...or the associated

        display.stop()

But that's not the problem, of course, as you're getting an error in the

    browser = webdriver.Firefox()

line, which is before those.

I'm wondering if it might be related to the fact that you're almost out of disk space? Try clearing down some files and see if that helps. (Selenium has probably been filling up your /tmp/ directory, it has a bad habit of doing that -- rm -rf /tmp/* in a bash console will delete everything from there.)

I tried above code still its not working and also it says 17% full (87.3 MB of your 512.0 MB quota)

what error do you see?

check /tmp and other locations for potential places taking up storage. selenium tends to leave files there.