Note that there are some explanatory texts on larger screens.

plurals
  1. POPython selenium webdriver - driver suddenly "dies" and can't quit, get current_url, open pages
    text
    copied!<p>Sometimes, in the middle of my script, my webdriver instance will just <em>die</em>!</p> <p>And thenceforth, I can't invoke any of its methods. </p> <p>Some examples:</p> <pre><code>&gt;&gt;&gt; spsel.driver.current_url Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 414, in current_url return self.execute(Command.GET_CURRENT_URL)['value'] File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 151, in execute response = self.command_executor.execute(driver_command, params) File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 280, in execute return self._request(url, method=command_info[0], data=data) File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 321, in _request response = opener.open(request) File "/usr/lib/python2.6/urllib2.py", line 391, in open response = self._open(req, data) File "/usr/lib/python2.6/urllib2.py", line 409, in _open '_open', req) File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain result = func(*args) File "/usr/lib/python2.6/urllib2.py", line 1161, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib/python2.6/urllib2.py", line 1136, in do_open raise URLError(err) urllib2.URLError: &lt;urlopen error [Errno 111] Connection refused&gt; &gt;&gt;&gt; spsel.driver.quit() Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 55, in quit RemoteWebDriver.quit(self) File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 443, in quit self.execute(Command.QUIT) File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 151, in execute response = self.command_executor.execute(driver_command, params) File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 280, in execute return self._request(url, method=command_info[0], data=data) File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 321, in _request response = opener.open(request) File "/usr/lib/python2.6/urllib2.py", line 391, in open response = self._open(req, data) File "/usr/lib/python2.6/urllib2.py", line 409, in _open '_open', req) File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain result = func(*args) File "/usr/lib/python2.6/urllib2.py", line 1161, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib/python2.6/urllib2.py", line 1136, in do_open raise URLError(err) urllib2.URLError: &lt;urlopen error [Errno 111] Connection refused&gt; </code></pre> <p>Any ideas why this might be the case? Any best practice solutions for overcoming?</p> <p>I'm thinking of occasionally testing for liveness by <code>driver.current_url</code> in a try block, and if it throws an exception, then setting the driver to <code>None</code>, and then re-instantiating it... but it's an ugly hack and I don't understand why it's needed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload