[🐛 Bug]:docker-seleniarm can not work with proxy #74
Description
cannot work with proxy
setup docker standalone-chromium svc and proxy locally, the proxy will not work;
step1: setup standalone-chromium
docker run --rm -it -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 2g seleniarm/standalone-chromium:latest
step2: set up proxy and check it correctly
step3: setup webdriver locally, seems right
this is my whole code script`
from selenium import webdriver
import os
from browsermobproxy import Server, Client
from selenium.webdriver.common.proxy import ProxyType,Proxy
import time
import json
from dotenv import load_dotenv
load_dotenv()
browsermob_path = os.getenv('BROWSERMOB_PATH')
server = Server(browsermob_path)
server.start()
proxy = server.create_proxy()
options = webdriver.ChromeOptions()
options.add_argument('--ignore-ssl-errors=yes')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--headless')
options.add_argument('--no-sandbox') # fix:DevToolsActivePort file doesn't exist
options.add_argument('--disable-dev-shm-usage') # fix:DevToolsActivePort file doesn't exist
options.add_argument('--remote-debugging-port=9222')
options.add_argument('--ignore-certificate-errors')
proxyStr = proxy.proxy
proxyStr = proxyStr.replace("localhost", "host.docker.internal")
print("proxy:",proxyStr, type(proxyStr),'--proxy-server=http://{0}'.format(proxy.proxy))
webdriver.DesiredCapabilities.CHROME['proxy'] = {
"httpProxy": proxyStr,
"ftpProxy": proxyStr,
"sslProxy": proxyStr,
"proxyType": "MANUAL",
}
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
options=options
)
print("webdriver.Remote, set up sucessful")
url = "http://example.com"
proxy.new_har(url, options={'captureContent': True})
driver.get(url)
time.sleep(30)
print(json.dumps(proxy.har, indent=4))
server.stop()
driver.quit()
`
Command used to start Selenium Grid with Docker (or Kubernetes)
docker run --rm -it -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 2g seleniarm/standalone-chromium:latest
Relevant log output
07:38:53.044 INFO [LocalDistributor.newSession] - Session request received by the Distributor:
[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--ignore-ssl-errors=yes, --ignore-certificate-errors, --headless, --no-sandbox, --disable-dev-shm-usage, --remote-debugging-port=9222, --ignore-certificate-errors], extensions: []}, pageLoadStrategy: normal}]
07:38:53.357 INFO [LocalNode.newSession] - Session created by the Node. Id: 92f07ee24ad6b4c6d8fdd9f211b5d53e, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome-headless-shell, browserVersion: 123.0.6312.86, chrome: {chromedriverVersion: 123.0.6312.86 (9b72c47a0536..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:9222}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://172.17.0.2:4444/sessio..., se:cdpVersion: 123.0.6312.86, se:vnc: ws://172.17.0.2:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.17.0.2: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}
07:38:53.361 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: 92f07ee24ad6b4c6d8fdd9f211b5d53e
Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome-headless-shell, browserVersion: 123.0.6312.86, chrome: {chromedriverVersion: 123.0.6312.86 (9b72c47a0536..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:9222}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://172.17.0.2:4444/sessio..., se:cdpVersion: 123.0.6312.86, se:vnc: ws://172.17.0.2:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.17.0.2: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}
Operating System
macos
Docker Selenium version (image tag)
latest
Selenium Grid chart version (chart version)
No response