1

Could not launch the browser (Chrome, Edge, etc) I have latest build of Chrome : 126, Selenium : 4.22.0, java.version: '22.0.1'.

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: 'DESKTOP-KT75J6U', ip: '192.168.1.37'
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:232)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:161)
    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 framework.BrowserTest.main(BrowserTest.java:9)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to bind the port.
Build info: version: '4.22.0', revision: 'c5f3146703*'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '22.0.1'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:249)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:117)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
    ... 7 more
5
  • what Could be the reason? Any Suggestions are welcome. Commented Jul 8 at 13:46
  • Can you please share a code snippet of how the driver is being initialized? Commented Jul 8 at 14:51
  • Hi There, please take a look. import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class BrowserTest { public static void main(String[] args) { WebDriver driver = new ChromeDriver(); driver.get("google.com"); } } In pom file i have java selenium - 4.22.0 Commented Jul 8 at 16:52
  • Do you have the chromedriver downloaded on the machine? or are you using WebDriverManager or SeleniumManager to manage those executables? Commented Jul 8 at 17:31
  • I tried both ways: I Downloaded The stable 126 chromedriver.exe, set the system property and tried running the test but failed(Could not launch the browser) later i removed it used SeleniumManager to launch it, same thing happened.(Binaries downloaded) but could not launch the browser. Commented Jul 9 at 6:17

1 Answer 1

0

somewhere your chromium is configured to use a remote driver instead of a local one. In my case, it was an extra dependency that I removed

org.seleniumhq.selenium:selenium-remote-driver

Another place to look, as it turned out, Selenium does not have a good enough error handling. I recommend double-checking whether the path to the binary is set up correctly. IMPORTANT: as I discovered, the path should not have spaces or special characters. If there are any, it crashes with a very vague error

var options = new ChromeOptions();        
options.setBinary("/path/to/chromium/chromium.app/Contents/MacOS/chromium");
1
  • 1
    to the people who are facing same issue, one catch is there that do not user java 22 version, use java 17 Commented Jul 10 at 5:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.