Simon Meusel
Simon Meusel

Reputation: 230

Close program when browser closes

I'm creating a Chrome driver like so:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary(CHROME);
chromeOptions.addArguments("user-data-dir=" + USER_DATA_DIR);

ChromeDriver chromeDriver = new ChromeDriver(chromeOptions);

If i close the browser (by clicking the red X) my java program just keeps alive. I then have to click the terminate button in Eclipse. How can i exit it automaticly when the browser closes?

Upvotes: 0

Views: 467

Answers (1)

Guy
Guy

Reputation: 50809

Selenium can't recognize manual operations on the browser. To terminate the program automatically close the browser using driver.close();

Upvotes: 1

Related Questions