I am also considering this error. I tried using the browser.close () method, and although it stops the object - โNoneTypeโ does not have the โpathโ attribute - from the displayed one I leave a bunch of open instances of the Firefox browser.
The .close () method closes chrome and it does not throw a NoneType error in firefox, but leaves Firefox open. The .quit () method closes both browsers, but it throws an error for firefox.
I am using the django class StaticLiveServerTestCase for my code.
I wrote a small debugger loop to check everything. Just uncomment and comment out the .quit () and .close () expressions.
class BaseTestCase(StaticLiveServerTestCase): @classmethod def setUp(self): self.firefox = webdriver.Firefox() self.chrome = webdriver.Chrome() self.browsers = [self.firefox, self.chrome] @classmethod def tearDown(self): for browser in self.browsers: if browser == self.firefox: print('firefox') browser.close()
I still don't know the answer, but I think this is a step in the right direction.
source share