Skip to content

[🐛 Bug]: WebDriverException while using Basic Auth #15745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sathanRaj opened this issue May 15, 2025 · 2 comments
Open

[🐛 Bug]: WebDriverException while using Basic Auth #15745

sathanRaj opened this issue May 15, 2025 · 2 comments
Labels
A-needs-triaging A Selenium member will evaluate this soon! B-grid Everything grid and server related C-java Java Bindings I-defect Something is not working as intended OS-mac

Comments

@sathanRaj
Copy link

sathanRaj commented May 15, 2025

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
@sathanRaj sathanRaj added I-defect Something is not working as intended A-needs-triaging A Selenium member will evaluate this soon! labels May 15, 2025
@selenium-ci
Copy link
Member

@sathanRaj, thank you for creating this issue. We will troubleshoot it as soon as we can.

Selenium Triage Team: remember to follow the Triage Guide

@github-actions github-actions bot added B-grid Everything grid and server related C-java Java Bindings OS-mac labels May 15, 2025
Copy link

⚠️ You reported using Selenium version 4.31.0, but the latest release is 4.32.

Please verify that this issue still occurs with the latest version. If it no longer applies, you can close this issue or update your comment.

This issue will be marked "awaiting answer" and may be closed automatically if no response is received.

@github-actions github-actions bot added J-awaiting answer Question asked of user; a reply moves it to triage again A-needs-triaging A Selenium member will evaluate this soon! and removed A-needs-triaging A Selenium member will evaluate this soon! J-awaiting answer Question asked of user; a reply moves it to triage again labels May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! B-grid Everything grid and server related C-java Java Bindings I-defect Something is not working as intended OS-mac
Projects
None yet
Development

No branches or pull requests

2 participants