Reputation: 13
My Chrome Browser on the test machine has been updated to 122.0.6261.70 but has stopped my tests working with the error,
SessionNotCreated Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
I am using the bonigarcia webdrivermanager dependency 5.7.0, in my Maven project to manage the Webdriver, but cannot for the life of me figure out how do fix the error that the session can't be started.
This is the code to launch the browser
''' @BeforeTest public void LaunchBrowser() {
System.setProperty("webdriver.http.factory", "jdk-http-client");
// Chrome browser setup
WebDriverManager.chromedriver().setup();
//Call getDownloadedDriverPath() to rerieve the path
String downloadedDriverPath = getDownloadedDriverPath();
System.out.println("Downloaded driver path: " + downloadedDriverPath);
// Call getDownloadedDriverPath() to retrieve the version
String downloadedDriverVersion = getDownloadedDriverVersion();
System.out.println("Downloaded driver version: " + downloadedDriverVersion);
// Configure Chrome options
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");
// Initialize ChromeDriver with options
driver = new ChromeDriver(options);
driver.manage().window().maximize();
// Define an array of possible options
String[] paths = {
"App1",
"App2",
"App3"
};
// Get a random option from the array
Random rand = new Random();
selectedPath = paths[rand.nextInt(paths.length)];
// Get the corresponding app name for the selected path
appName = getAppName(selectedPath);
// Use the appName variable in other parts of the test
System.out.println("Selected App: " + appName);
driver.get("https://portal-test.homeapphub.com/anonymous/signup/" + selectedPath);
}
'''
Here is my output, running Selenium Java 4.18.1
'''
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files (x86)\OpenText\UFT One\bin\java_shared\classes\jasmine.jar"
[INFO] Running TestSuite
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.
Downloaded driver path: null
Downloaded driver version: null
FAILED CONFIGURATION: @BeforeTest RPSPortal.LaunchBrowser
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: 'WILSON-GAMING', ip: '169.254.54.228'
Build info: version: '4.18.1', revision: 'b1d3319b48'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '21.0.2'
Driver info: org.openqa.selenium.chrome.ChromeDriver
'''
Upvotes: 0
Views: 236
Reputation: 13
Solved. I was missing the following dependency
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-http</artifactId>
<version>4.18.1</version>
</dependency>
Adding that in has resolved it although not sure why it ran before without that.
Upvotes: 0