I am new in selenium and i am trying to open a page so chome open but it can not load URL.
Code trials:
System.setProperty("webdriver.chrome.driver","C:\\Users\\user\\Desktop\\ecli\\chromedriver.exe")
WebDriver driver= new ChromeDriver();
driver.get("https://rahulshettyacademy.com/");
System.out.println(driver.getTitle());
I tried re install chrome, add thread.sleep(5000)
, add dependency WebDriverManager.chromedriver().setup();
and WebDriver driver = new ChromeDriver();
After close the chrome I have this:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Starting ChromeDriver 103.0.5060.134 (8ec6fce403b3feb0869b0732eda8bd95011d333c-refs/branch-heads/5060@{#1262}) on port 54404
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: DevToolsActivePort file doesn't exist
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'PC', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.3'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}}}]
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:144)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:264)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:179)
at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:101)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:81)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:49)
at PrimerEjercicio.main(PrimerEjercicio.java:29)
Environment:
- OS: W10
- Chrome version :104.0.5112.102
- jve1.8.0_101 (java version)
CodePudding user response:
This error message...
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: DevToolsActivePort file doesn't exist
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. google-chrome session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- You are using chrome=104.0
- But you are using chromedriver=103.0
- Release Notes of chromedriver=103.0 clearly mentions the following :
Supports Chrome version 103
So there is a clear mismatch between chromedriver=103.0 and the chrome=104.0
Solution
Ensure that:
- Selenium is upgraded to current released Version 4.4.0.
- ChromeDriver is updated to current ChromeDriver v104.0 level.
- Chrome Browser is updated to current chrome=104.0 (as per chromedriver=104.0 release notes).
CodePudding user response:
Sorry, cant comment undetected Seleniums post, because i a m new to stackoverflow.
In general you have to make sure, that the majorversion of your chromedriver matches the mainversion of your chrome browser.
Geckodriver is more forgiving, but still it is better to make sure you are up to date with the driver.