-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
What happened?
While attempting to create a new session using Selenium and ChromeDriver, the following error occurred:
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created from unknown error: cannot create temp dir for user data dir
After investigation, I found that this issue is caused by Windows Real-Time Protection, which prevents the creation of temporary directories required for ChromeDriver.
##(need to mention that after figuring out the problem and disabling Windows real-time protection and leaving my laptop for a couple of hours, and then trying to rerun a test while Windows real-time protection was still disabled the error occurred again so I enabled then disabled Windows real-time protection and the error was gone {this happened only 1 time} )
How can we reproduce the issue?
1- Ensure Windows Real-Time Protection is enabled.
2- Use the following environment details:
- OS: Windows 11 (64-bit) version 24H2
- Selenium version: 4.27.0
- ChromeDriver version: 131.0.6778.204
- Browser: Google Chrome (Version 131.0.6778.205 (Official Build) (64-bit)).
3-Code to reproduce:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Tests {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");
}
}Relevant log output
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created
from unknown error: cannot create temp dir for user data dir
Host info: host: 'RED_CLOUD2000', ip: '###.###.###.#'
Build info: version: '4.27.0', revision: 'd6e718d134'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '21.0.5'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], binary: C:\Program Files\Google\Chr..., extensions: []}}]}]
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:162)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:245)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:174)
at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:114)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:51)
at Tests.main(Tests.java:6)
Process finished with exit code 1Operating System
Windows 11 (64-bit) version 24H2
Selenium version
Java 4.27.0
What are the browser(s) and version(s) where you see this issue?
Google Chrome (Version 131.0.6778.205 (Official Build) (64-bit)).
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver version: 131.0.6778.204
Are you using Selenium Grid?
No
