I've just installed Selenium for the first time, and I'm having trouble to get started.
Installation went fine with
pip install selenium
from selenium import webdriver
driver = webdriver.Firefox()
assert "Python" in driver.title
Traceback (most recent call last):
File "selenium-test.py", line 4, in <module>
driver = webdriver.Firefox()
File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 61, in __init__
File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 72, in __init__
File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 114, in start_session
File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 136, in check_response
selenium.common.exceptions.WebDriverException: Message: u'<HTML><HEAD>\r\n<TITLE>Network Error</TITLE>\r\n</HEAD>\r\n<BODY>\r\n<FONT face="Helvetica">\r\n<big><strong></strong></big><BR>\r\n</FONT>\r\n<blockquote>\r\n<TABLE border=0 cellPadding=1 width="80%">\r\n<TR><TD>\r\n<FONT face="Helvetica">\r\n<big>Network Error (tcp_error)</big>\r\n<BR>\r\n<BR>\r\n</FONT>\r\n</TD></TR>\r\n<TR><TD>\r\n<FONT face="Helvetica">\r\nA communication error occurred: "Operation timed out"\r\n</FONT>\r\n</TD></TR>\r\n<TR><TD>\r\n<FONT face="Helvetica">\r\nThe Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.\r\n</FONT>\r\n</TD></TR>\r\n<TR><TD>\r\n<FONT face="Helvetica" SIZE=2>\r\n<BR>\r\nFor assistance, contact your network support team.\r\n</FONT>\r\n</TD></TR>\r\n</TABLE>\r\n</blockquote>\r\n</FONT>\r\n</BODY></HTML>'
Ok, after searching around for a while I noticed that usually the problem was a bug in Selenium (possible, but rather unlikely), or a proxy issue. Still, none of the answers suggesting how to solve the proxy issue seemed to work.
Finally I got it: you need to unset all proxy settings everywhere (environment variables, and - in my case this was the issue- on Gnome). Later when you create the webdriver, you need to pass a profile which sets the browser proxy settings to what you actually use (in my case an automatic config url)
1) Unset the
http_proxy environment variable (which is used by
2) Cleared Gnome proxy settings: System --> Preferences --> Network Proxy --> Select "Direct Internet Connection"
webdriver.Firefox() with a profile which configures the proxy (in this case it's an automatic proxy configuration)
fp = webdriver.FirefoxProfile() # Here "2" stands for "Automatic Proxy Configuration" fp.set_preference("network.proxy.type", 2) fp.set_preference("network.proxy.autoconfig_url", "http://proxy-address-here:8080/") driver = webdriver.Firefox(firefox_profile=fp)