Could not start a new session. Response code 404

I can get both Android and iOS test to work.

It’s clearly something with Chrome.

I’m keep digging and update you with my findings.

Thanks for assisting.

1 Like

I fixed the this issue by updating by selenium-server in the pom.xml

The method setPlatformName(String) is undefined for the type
ChromeOptions

The method setBrowserVersion(String) is undefined for the type
ChromeOptions

org.seleniumhq.selenium selenium-server 4.0.0-alpha-2

However, when I run using’

ChromeOptions browserOptions = new ChromeOptions();
browserOptions.setPlatformName(“MAC”);
browserOptions.setBrowserVersion(“113”);

May 17, 2023 12:57:53 PM org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryTracer createTracer

INFO: Using OpenTelemetry for tracing

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 404. Message: Unable to find handler for (POST) /session

Host info: host: ‘MacBook-Pro-2.local’, ip: ‘fe80:0:0:0:cef:4700:3ba6:d476%en0’

Build info: version: ‘4.9.0’, revision: ‘d7057100a6’

System info: os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘13.3.1’, java.version: ‘1.8.0_371’

I really think you shouldn’t be using ChromeOptions at all. No luck with a setup like that last link I posted? Seems pretty straightforward.

When I step through this :point_down:

threadDriver.set(new RemoteWebDriver(new URL(“http://localhost:6666”), browserOptions));

It goes into the below function

protected void startSession(Capabilities capabilities) {
checkNonW3CCapabilities(capabilities);
checkChromeW3CFalse(capabilities);

Response response = execute(DriverCommand.NEW_SESSION(singleton(capabilities)));

// I think I am missing something in the capabilities, because it fails to generate a new session.
Capabiliities = Capabilities {browserName: chrome, browserVersion: 113, goog:chromeOptions: {args: [–remote-allow-origins=*], extensions: []}, platformName: MAC}

From everything I’m reading it should work.

I’m going to post on this form to see if anyone else has had this isssue.

https://groups.google.com/g/selenium-users

1 Like

Below is the link to the selenium google group thread that I opened.

https://groups.google.com/g/selenium-users/c/MMmiXzE5IMw

Case Closed. I figured it out.

switch (strBrowser)
{
case “Chrome”:
try
{
//This works
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
if (strHeadless.equals(“True”))
{chromeOptions.addArguments("–headless");}
WebDriver driver = new ChromeDriver(chromeOptions);
RemoteWebDriver remoteDriver = (RemoteWebDriver) driver;
ThreadLocal threadDriver = new ThreadLocal<>();
threadDriver.set(remoteDriver);
return threadDriver;
}
catch (Exception e)
{
e.printStackTrace();
System.out.println(“MIH”);
}
break;
}

Ok, just so I’m understanding the difference between the original code.

  1. You set your ChromeOptions
  2. You instantiate WebDriver with them (without URL)
  3. You instantiate RemoteDriver by casting WebDriver to RemoteDriver

Have I got that right?

A long time ago I was having issues with run tests in parallel on the same machine, so in order to get around it I threaded the browser. This worked, but I don’t really need it anymore except that “ThreadLocal” now embedded throughout my code, so needless to say I need to get around it once I updated to selenium-server-4.9.1.

Basically what you are saying is True.

Before I was associating the chrome browser to a selenium node, but I don’t think it mattered since I was threading the browsers.

Probably not the best way to handle it, but again it worked when I only had 1 lab machine and I need to kick of iOS and Android tests in parallel that both required browser validations.

1 Like