I want to perform logic on chrome.window.onRemoved.addListener(), it works exactly in chrome browser development environment and in selenium when performed with browser UI of selenium test, but when I execute driver.quit(); in python shell the onRemoved event is not performed.

How can I trigger chrome browsers window.onRemoved/(any event before window close to get handled in the extension) event in selenium test while applying Webdrive.quit();?

2 Answers 2


Refer to this question:


chrome.window.onRemoved.addListener(), works only when a chrome process is running. The `driver.quit()` closes all the  chrome processes.

Use driver.close()


Could you try this :

// Initializing instance of Firefox WebDriver
    driver = new ChromeDriver();
    wait = new WebDriverWait(driver, waitTime);

// Initializing EventFiringWebDriver using Firefox WebDriver instance
    e_driver = new EventFiringWebDriver(driver);

//create object of EventListerHandler to registeritwithEventFiringWebDriver
        eventListener = new WebEventListener();



Did you try driver.close()?

Quit() kills the browser, which probably does not give it the chance the trigger the events. Close() closes the active window but the browser stays open, although if it is the last window it might quit aswell, maybe you need to open an extra window first.

  • yes, on using driver.close() it quits browser as it is only the window. Also I tried to use key commands ALT + F4 but it is also not working. Jan 23, 2020 at 18:10
  • After brainstorming on this so much I concluded that there at in this case derivr.quit() is not real implementation of closing chrome browser like real browser, and it must be improved. Jan 23, 2020 at 18:14
  • thanks for taking look @Neils van Jan 23, 2020 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.