error with Firefox Binary 'The browser appears to have exited'

mahmoud alnafei squ106595 at
Sun Apr 12 21:44:06 CEST 2015

I have problem with selenium and Firefox when i run my code below:

    from selenium import webdriver
    from selenium.common.exceptions import TimeoutException
    from import WebDriverWait
    from import expected_conditions as EC
    from bs4 import BeautifulSoup
    import urllib2,cookielib
    import re
    from pyvirtualdisplay import Display
    import urllib
    import urllib2
    import httplib2
    from os import system

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

    name = 'test'
    driver = webdriver.Firefox()
    inputElement = driver.find_element_by_name("name")
    print "Please wait for 5s to get results.."
    content = driver.page_source.encode("utf-8")
    html = str(content)
    soup = BeautifulSoup(html)
    print soup

And i get this error:

    Exception in thread command9:
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/", line 551, in __bootstrap_inner
      File "/usr/local/lib/python2.7/", line 504, in run
        self.__target(*self.__args, **self.__kwargs)
      File "plugins/", line 165, in handler_search
        search_number_ar(type, source, parameters)
      File "plugins/", line 230, in search_test
        driver = webdriver.Firefox()
      File "/usr/local/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/", line 59, in __init__
        self.binary, timeout),
      File "/usr/local/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/", line 47, in __init__
      File "/usr/local/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/", line 66, in launch_browser
      File "/usr/local/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/", line 100, in _wait_until_connectable
        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.

my code running in vps and i use selenium-2.45.0 and firefox-38.0b3 . I try alot of ways to solve my problem but nothing working with me. I try to update selenium and i try to downgrade firefox and alot of solution.

Just to know when i run my code for the first time it work but when i run it again it show me the above error.
I have Python2.7 .

I hope someone help me.

More information about the Python-list mailing list