When running Selenium Webdriver Python script, one gets a 'NoneType' object has no attribute 'path'
after executing self.driver.quit().
Enclosing self.driver.quit()
in try/except
does not help, namely:
$ cat demo_NoneType_attribute_error.py
# -*- coding: utf-8 -*-
from selenium import webdriver
import unittest
class TestPass(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
def test_pass(self):
pass
def tearDown(self):
print("doing: self.driver.quit()")
try:
self.driver.quit()
except AttributeError:
pass
if __name__ == "__main__":
unittest.main()
$ python demo_NoneType_attribute_error.py
doing: self.driver.quit()
'NoneType' object has no attribute 'path'
.
----------------------------------------------------------------------
Ran 1 test in 19.807s
OK
$
Does anyone have an idea how to avoid the 'NoneType' object has no attribute 'path'
message?
Note:
Since this issue was already reported by the beginning of November (see URLs below), it should have had a patch by now - but upgrading selenium
to latest from pip
did not eliminate it.
- Exception AttributeError: "'NoneType' object has no attribute 'path'" in
- Exception AttributeError: "'NoneType' object has no attribute 'path'" in
Environment: Selenium 3.0.2; Python 2.7; Cygwin 32 bits on Windows 7.