0

My selenium setup is:

WebDriverManager.chromedriver().setup();
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--remote-allow-origins=*");
ops.addArguments("--disable-popup-blocking");
ops.addArguments("--disable-notifications");
ops.addArguments("--disable-infobars");
ops.addArguments("--disable-extensions");
ops.addArguments("--start-maximized");
ops.addArguments("--guest");
ops.addArguments("--no-first-run");
ops.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
ops.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
baseDriver = new ChromeDriver(ops);

With this, I see error while launching test:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

I also tried to add unique value for 'use-data-dir' as suggested in errormessage:

Path tempProfileDir = Files.createTempDirectory("selenium-profile");
ops.addArguments("--user-data-dir=" + tempProfileDir.toAbsolutePath())

But this too has same issue.

What am I missing?

Edit:

I see that chrome settings show version as '138.0.7204.97', while when selenium test runs, it downloads '138.0.7204.92' at '....cache\selenium\chromedriver\win64'. Can this mismatch be the issue? And can I force it to use correct version?

Another Edit:

I forced it to use 138.0.7204.97,and now downloaded version is same too. But I still see same error.

1
  • That is just a generic error that Chrome couldn't launch. Try running Chrome from the command line to see what the actual error/reason is. Commented Jul 7 at 2:37

1 Answer 1

0

Check out the Chrome version by typing into the address bar "chrome://version/". Take a look at the "Profile Path", I have seen that the new update to chrome has a new profile automatically added in the "...AppData\Local\Google\Chrome\<new folder>\Default" and all chrome instances are using the same even when you specify it in the selenium chrome options.
From what I can tell, if you have a Chrome browser opened while running your automation script, the new Chrome browser started by the chrome driver will try to use the same user data folder as the one that is already opened. The chrome driver will not be able to access/update the user data files if it is already being in use.
I do not know what the fix is for this new issue, but you can work around it by switching to a different browser if you need to have a browser open and by not having another instance of Chrome running while you are running your automation scripts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.