Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I'm getting the chrome didn't shut down correctly error message when I reopen a chrome browser in my selenium framework.

In the framework I'm opening the browser instance at the beginning for each of my test case using the below code

if (browserType.equalsIgnoreCase("Chrome")) {

            try {                               

                System.setProperty("webdriver.chrome.driver", curProj+"\\drivers\\chromedriver.exe");

                ChromeOptions options = new ChromeOptions();

                options.setExperimentalOption("useAutomationExtension", false);

                options.addArguments("disable-infobars");

                //options.addArguments("user-data-dir=C:/Users/xw20/AppData/Local/Google/Chrome/User Data");

                options.addArguments(chromeProfile);

                webdriver = new ChromeDriver(options);

                logger.info("getWebDriver - Setting webdriver.chrome.driver system property as: " + System.getProperty("webdriver.chrome.driver"));

            }

            catch(IllegalStateException e) {

                logger.error("The path to the driver executable must be set by the webdriver.chrome.driver system property. ",e.fillInStackTrace());

                throw new IllegalStateException("The path to the driver executable must be set by the webdriver.chrome.driver system property.");

            }

and closing at the end using the below code

driver.close();

driver.quit();

But when I open a browser for the second test case I'm getting "chrome didn't shut down correctly" popup message.

I tried updating the below in the Preferences file of chrome profile but no luck

exit_type:Crashed

exited_cleanly:true

Configuration :

Chrome Version: Version 64.0.3282.186 (Official Build) (32-bit)

Selenium Version: 3.11.0

1 Answer

0 votes
by (62.9k points)

As per your code, it would be tough to analyze the reason behind the error chrome didn't shut down correctly without knowing your framework structure. Perhaps more details about how to code block was invoked (i.e. main() or TestNG) would have helped us.

 

Having said that there still seems some more factors to look at as follows :

 

If you are using an existing Chrome Profile through user-data-dir ideally you should avoid the switches setExperimentalOption and addArguments for customization as those should be set within the respective Chrome Profile.

As you are using an existing Chrome Profile through user-data-dir as per the documentation ChromeDriver - WebDriver for Chrome the path should point the profile directory as follows :

 

options.add_argument("user-data-dir=C:/Users/xw20/AppData/Local/Google/Chrome/User Data/Profile 2")

 

Avoid using the driver.close(); always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...