0

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.x86_64-31.6.0. 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 hope someone help.

yuyb0y
  • 3
  • 6
  • What if you try with the latest firefox and selenium 2.45? – alecxe Apr 07 '15 at 18:18
  • @alecxe thank you for your replay. `firefox.x86_64-31.6.0` its the latest version. – yuyb0y Apr 07 '15 at 18:40
  • Thank you for the reply, [firefox 37.0.1](https://www.mozilla.org/en-US/firefox/new/) is currently the latest. – alecxe Apr 07 '15 at 18:44
  • @alecxe yeah i see that now. can you please tell me how to install the latest version of firefox ? – yuyb0y Apr 07 '15 at 18:59
  • Installed: firefox.x86_64 0:31.6.0-2.el6.centos Complete! @yuyb0y [~]# yum update firefox Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Update Process Loading mirror speeds from cached hostfile No Packages marked for Update – yuyb0y Apr 07 '15 at 20:01
  • @alecxe I was update firefox to `Mozilla Firefox 38.0` version and with `selenium-2.45.0` version but i get the same problem. To know i'm using `python2.7` . please need help – yuyb0y Apr 10 '15 at 13:10

0 Answers0