Open
Description
Description
I'm using selenium grid for automation and configured user name and password for hub.
when the the webdriver actions(geturl,screenshot,click) triggered too frequently session terminates after 180 secs.
working fine when there is no authentication configured
Reproducible Code
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.UsernameAndPassword;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.HttpCommandExecutor;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.http.ClientConfig;
import java.io.File;
import java.net.URL;
import java.time.Duration;
public class SeleniumBasicAuth{
public static void main(String[] args) {
WebDriver driver = null;
long startTime = System.currentTimeMillis();
try {
ChromeOptions options = new ChromeOptions();
options.setBrowserVersion("133");
options.setCapability("browserName","chrome");
options.addArguments("--headless=new");
driver = new RemoteWebDriver(getHttpCommandExecutor(),options);
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(180));
driver.manage().timeouts().scriptTimeout(Duration.ofSeconds(180));
driver.manage().deleteAllCookies();
for (int i=0;i<500;i++){
System.out.println(i);
driver.get("https://qengine.zoho.com/");
takeSnapShot(driver,"Screenshots"+File.separator+i+".jpg");
}
}
catch (Exception e){
e.printStackTrace();
}
finally {
if (driver != null){
driver.quit();
}
System.out.println(((System.currentTimeMillis()-startTime)/1000));
}
}
public static void takeSnapShot(WebDriver webdriver, String fileWithPath) throws Exception{
TakesScreenshot scrShot =((TakesScreenshot)webdriver);
File SrcFile=scrShot.getScreenshotAs(OutputType.FILE);
File DestFile=new File(fileWithPath);
FileUtils.copyFile(SrcFile, DestFile);
}
private static HttpCommandExecutor getHttpCommandExecutor() throws Exception {
ClientConfig clientConfig = ClientConfig.defaultConfig()
.baseUrl(new URL("http://localhost:8444"))
.authenticateAs(new UsernameAndPassword("password","myStrongPassword"))
;
HttpCommandExecutor executor = new HttpCommandExecutor(clientConfig);
return executor;
}
}
Debugging Logs
13-May-2025 11:42:36.064 WARNING [pool-6-thread-1] org.openqa.selenium.remote.tracing.opentelemetry.SeleniumSpanExporter$1.lambda$export$1 org.openqa.selenium.WebDriverException: Build info: version: '4.31.0', revision: '4ae8fc9f8a'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.106', java.version: '11.0.14.1'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute(JdkHttpClient.java:419)
at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:54)
at org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:91)
at org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:183)
at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:397)
at org.openqa.selenium.remote.http.Route.execute(Route.java:69)
at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:360)
at org.openqa.selenium.remote.http.Route.execute(Route.java:69)
at org.openqa.selenium.grid.router.Router.execute(Router.java:89)
at org.openqa.selenium.grid.web.CheckOriginHeader.lambda$apply$0(CheckOriginHeader.java:69)
at org.openqa.selenium.grid.web.CheckContentTypeHeader.lambda$apply$0(CheckContentTypeHeader.java:75)
at org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)
at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:63)
at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:360)
at org.openqa.selenium.remote.http.Route.execute(Route.java:69)
at org.openqa.selenium.remote.http.Route$NestedRoute.handle(Route.java:270)
at org.openqa.selenium.remote.http.Route.execute(Route.java:69)
at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:360)
at org.openqa.selenium.remote.http.Route.execute(Route.java:69)
at org.openqa.selenium.grid.security.BasicAuthenticationFilter.lambda$apply$0(BasicAuthenticationFilter.java:54)
at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:63)
at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:360)
at org.openqa.selenium.remote.http.Route.execute(Route.java:69)
at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)
at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:63)
at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:63)
at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:49)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.InterruptedException
at java.base/java.util.concurrent.CompletableFuture.reportGet(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute(JdkHttpClient.java:413)
... 33 more