6 examples of 'how to close browser in selenium' in Python

Every line of 'how to close browser in selenium' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
58def close_browser(self, browser):
59 browser.close()
60 self.__class__.browsers.remove(browser)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

23def quit(self, force=False):
24 if self._has_quit:
25 return
26 if self.reuse_browser and not force:
27 # alert = self.alert
28 # if alert:
29 # alert.dismiss()
30 return
31 super(WebDriverMixin, self).quit()
32 self._has_quit = True
182@classmethod
183def cleanup_browser(cls):
184 if cls._driver:
185 cls._driver.quit()
186 cls._driver = None
63def __close_browser(context):
64 context.driver.close()
186def quit(self):
187 """
188 Closes the browser and shuts down the ChromiumDriver executable
189 that is started when starting the ChromiumDriver
190 """
191 try:
192 RemoteWebDriver.quit(self)
193 except Exception:
194 # We don't care about the message because something probably has gone wrong
195 pass
196 finally:
197 self.service.stop()
119@unittest.skipIf(os.getenv('TOX', False), 'Not test browser on TOX')
120@unittest.skipIf(os.getenv('TRAVIS', False), 'Not test browser on TRAVIS')
121def test_open_browser(self):
122 time.sleep(3)
123 # terminate server and gett all log
124 self.proc.terminate()
125 log = self.proc.stdout.read()
126 self.assertIn('Start server on', log)
127 self.assertIn('connected', log)

Related snippets