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

mahmoud alnafei squ106595 at gmail.com
Sun Apr 12 15:44:06 EDT 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 selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support 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))
    display.start()

    name = 'test'
    driver = webdriver.Firefox()
    driver.get("http://example.com")
    driver.switch_to_default_content()
    inputElement = driver.find_element_by_name("name")
    inputElement.send_keys(name)
    inputElement.submit()
    print "Please wait for 5s to get results.."
    content = driver.page_source.encode("utf-8")
    html = str(content)
    soup = BeautifulSoup(html)
    print soup
    display.stop()
    driver.close()




And i get this error:

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