Firefox Not Closing After Selenium Tests Are Run

Firefox windows don't close after Selenium test has run

Very simple solution in the end - just called SeleniumTestCase's tearDown() method (ie. we call super.tearDown(); from our base test class)

That closes down all the browser windows successfully.

Firefox not closing after selenium tests are run

The solution to this was to point Selenium at the firefox-bin file instead of the firefox file, which it may use by default if it's at /usr/bin/firefox.

This question explains how to specify a path to firefox-bin:
How to explicitly specify a path to Firefox for Selenium?

Why selenium Firefox WebDriver cannot close browser after test

It must have something to do with the name of the firefox binary? Maybe WebDriver expects it to be "firefox.exe" and the .exe your running is different? Or it could be something else along those lines. Maybe the portable firefox doesn't connect to firefox system profiles the same? I think your on your own on this one. Why is it required that you use the portable one?

If you find no solution, you could always write your own process killer method:

Runtime.getRuntime().exec("pkill firefox");

Selenium web driver not able to close firefox instance if a Test cases is failed

Add webdriver.quit() to an @AfterClass method.

close() will shut the current active window. If the current active window is the last window it is functionally equivalent to performing a quit().

It does however need to have a valid active session to be able to do this. If your test has failed that session is probably dead, so when you call a close() it doesn't know where to send the command and throws an Exception.

quit() will end all sessions and shut down all clients, it's basically a clean up everything command. It will also not throw any Exceptions if all clients/sessions have already been closed/ended.

python selenium driver.quit() can not quit firefox browser if firefox_profile setted

While we work with Selenium 3.5.0 with latest GeckoDriver v.0.18.0 and Mozilla Firefox 53.0, the browser window(s) initiated by the WebDriver instance is bound to get destroyed (killed) once you invoke the quit() on the WebDriver instance.

So the blank window which you are seeing may be a result of either some other user interactions or a dangling instance.

Recommendation:

You can consider the following steps to start a clean Test Execution:

  1. Run CCleaner tool to wipe out all the leftovers from your previous executions.
  2. Restart your system to start your Test Execution on a clean OS environment.
  3. Keep the Test Environment isolated from other User Interactions.


Related Topics



Leave a reply



Submit