How to reject-unsupported-caps in Selenium Grid hub and node

90 views Asked by At

I am testing different configurations for selenium grid 4 and in the official documentation is said that reject-unsupported-caps = true will "Allow the Distributor to reject a request immediately if the Grid does not support the requested capability."

To test the configuration locally I have hub and node with the following configurations:

#hubConfig.toml
[server]
port = 4444

[distributor]
healthcheck-interval = 10
reject-unsuported-caps = true

[logging]
structured-logs = true
log-file = "log/hubLog.log"
log-encoding = "UTF-8"
log-level = "CONFIG"
#nodeConfig.toml
[server]
port = 6666

[node]
detect-drivers = true
max-sessions = 2
heartbeat-period = 10
session-timeout = 300
hub = "http://localhost:4444"

[logging]
structured-logs = true
log-file = "log/nodeLog.log"
log-encoding = "UTF-8"
log-level = "CONFIG"

I am executing single test class maven/java/TestNG containing 3 tests. Two with correct capabilities(chrome,firefox) and one in safari. Example for the second test is below

@Test
public void test2() throws InterruptedException {
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(BROWSER_NAME,"safari");
    RemoteWebDriver remoteWebDriver = new RemoteWebDriver(gridURL,caps);
    remoteWebDriver.get("http://www.google.com");
    Thread.sleep(sleepTime);
    remoteWebDriver.quit();
}

My expectation is that this test should be rejected immediately, but it fails after session timeout.

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure
0

There are 0 answers