SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.18k stars 8.11k forks source link

[🐛 Bug]: why the docker image selenium/standalone-firefox supports proxy,but chrome doesn't? #14434

Open Ninjaxsh opened 3 weeks ago

Ninjaxsh commented 3 weeks ago

What happened?

Whenever I initial proxy in docker-compose environment or test in Java, The proxy does take effect in selenium/standalone-chrome,but it's availability in selenium/standalone-firefox.

How can we reproduce the issue?

In docker-compose's yml environment

    environment:
      - http_proxy=nx.testdomain.com:24000 # brightdata's proxy manager service

In java

    /**
     * @param browser   "edge|chrome|firefox"
     * @param webDriver "http://a.test.cn:50019/wd/hub";
     * @param targetUrl "htts://www.google.com"
     * @param proxy     "nx.testdomain.com:24000"
     * @param targetTag "app"
     * @return
     * @throws MalformedURLException
     */
    public static RemoteWebDriver remoteWebDriver(String browser, String webDriver, String targetUrl, String proxy, String targetTag) throws MalformedURLException {

        ChromeOptions chromeOptions = new ChromeOptions();
        FirefoxOptions firefoxOptions = new FirefoxOptions();
        EdgeOptions edgeOptions = new EdgeOptions();
        // 设置代理
        Proxy reqProxy = new Proxy();
        if (!proxy.equals("")) {
            reqProxy.setHttpProxy(proxy);
            chromeOptions.setProxy(reqProxy);
            firefoxOptions.setProxy(reqProxy);
            edgeOptions.setProxy(reqProxy);
        }
        URL url = new URL(webDriver);
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        if (browser.equals("chrome")) {
            desiredCapabilities.merge(chromeOptions);
        } else if (browser.equals("firefox")) {
            desiredCapabilities.merge(firefoxOptions);
        } else {
            desiredCapabilities.merge(edgeOptions);
        }
        desiredCapabilities.setCapability("acceptInsecureCerts", true);

        RemoteWebDriver remoteWebDriver = new RemoteWebDriver(url, desiredCapabilities);
        remoteWebDriver.get(targetUrl);
        WebDriverWait webDriverWait = new WebDriverWait(remoteWebDriver, Duration.ofSeconds(15));
        webDriverWait.until(d -> remoteWebDriver.findElement(By.id(targetTag)).isDisplayed());
        return remoteWebDriver;
    }

Relevant log output

###### 1、these are standalone-chrome's log

12:07:48.650 INFO [LocalDistributor.newSession] - Session request received by the Distributor: 
 [Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, proxy: {httpProxy: nx.testdomain.com:24000, proxyType: manual}}]
12:07:49.088 INFO [LocalNode.newSession] - Session created by the Node. Id: ee2846da01d726c62672a9ad5f06ded5, Caps: Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 127.0.6533.119, chrome: {chromedriverVersion: 127.0.6533.119 (bdef6783a05..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:44789}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(manual, http=nx.testdomain..., se:bidiEnabled: false, se:cdp: ws://172.18.0.24:4444/sessi..., se:cdpVersion: 127.0.6533.119, se:vnc: ws://172.18.0.24:4444/sessi..., se:vncEnabled: true, se:vncLocalAddress: ws://172.18.0.24:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
12:07:49.089 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: ee2846da01d726c62672a9ad5f06ded5 
 Caps: Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 127.0.6533.119, chrome: {chromedriverVersion: 127.0.6533.119 (bdef6783a05..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:44789}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(manual, http=nx.testdomain..., se:bidiEnabled: false, se:cdp: ws://172.18.0.24:4444/sessi..., se:cdpVersion: 127.0.6533.119, se:vnc: ws://172.18.0.24:4444/sessi..., se:vncEnabled: true, se:vncLocalAddress: ws://172.18.0.24:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}

###### 2、these are standalone-firefox's log

12:08:56.213 INFO [LocalDistributor.newSession] - Session request received by the Distributor: 
 [Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}, proxy: {httpProxy: nx.testdomain.com:24000, proxyType: manual}}]
12:08:58.553 INFO [LocalNode.newSession] - Session created by the Node. Id: d97c5984-027f-4793-afeb-f8913ce4668f, Caps: Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 129.0.1, moz:accessibilityChecks: false, moz:buildID: 20240812083845, moz:debuggerAddress: true, moz:firefoxOptions: {}, moz:geckodriverVersion: 0.35.0, moz:headless: false, moz:platformVersion: 5.15.0-119-generic, moz:processID: 35273, moz:profile: /tmp/rust_mozprofileIlS6Zj, moz:shutdownTimeout: 60000, moz:webdriverClick: true, moz:windowless: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(manual, http=nx.testdomain..., se:bidiEnabled: false, se:cdp: ws://172.18.0.23:4444/sessi..., se:containerName: , se:noVncPort: 7900, se:vnc: ws://172.18.0.23:4444/sessi..., se:vncEnabled: true, se:vncLocalAddress: ws://172.18.0.23:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, userAgent: Mozilla/5.0 (X11; Linux x86...}
12:08:58.554 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: d97c5984-027f-4793-afeb-f8913ce4668f 
 Caps: Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 129.0.1, moz:accessibilityChecks: false, moz:buildID: 20240812083845, moz:debuggerAddress: true, moz:firefoxOptions: {}, moz:geckodriverVersion: 0.35.0, moz:headless: false, moz:platformVersion: 5.15.0-119-generic, moz:processID: 35273, moz:profile: /tmp/rust_mozprofileIlS6Zj, moz:shutdownTimeout: 60000, moz:webdriverClick: true, moz:windowless: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(manual, http=nx.testdomain..., se:bidiEnabled: false, se:cdp: ws://172.18.0.23:4444/sessi..., se:containerName: , se:noVncPort: 7900, se:vnc: ws://172.18.0.23:4444/sessi..., se:vncEnabled: true, se:vncLocalAddress: ws://172.18.0.23:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, userAgent: Mozilla/5.0 (X11; Linux x86...}

Operating System

Ubuntu

Selenium version

latest

What are the browser(s) and version(s) where you see this issue?

browserName: chrome, browserVersion: 127.0.6533.119

What are the browser driver(s) and version(s) where you see this issue?

chromedriverVersion: 127.0.6533.119

Are you using Selenium Grid?

No response

github-actions[bot] commented 3 weeks ago

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


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!