You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.
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()
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)
Relevant log output
Operating System
macos
Docker Selenium version (image tag)
latest
Selenium Grid chart version (chart version)
No response
The text was updated successfully, but these errors were encountered: