我无法使用无头模式在Google Chrome中使用我当前安装的扩展程序.有没有办法启用它们?
检查扩展是否有效的简单方法是添加,例如," Comic Sans Everything "扩展.
谷歌看起来像这样:
但是,如果我使用无头模式(google-chrome --headless --disable-gpu --screenshot https://www.google.com)拍摄页面的屏幕截图,结果是:
google-chrome google-chrome-extension google-chrome-headless
我正在尝试在运行 alpine 的 Docker 容器中使用 Python 和 selenium 运行 chrome。它运行得很好,直到有一天,当我实例化 chrome 时,它开始抛出以下错误。
Message: unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Run Code Online (Sandbox Code Playgroud)
这是创建此错误的代码:
from selenium import webdriver
def generate_plugin():
pluginfile = 'proxy_auth_plugin.zip'
# manifest_json, background_js same as https://stackoverflow.com/a/61764363/9809865
with zipfile.ZipFile(pluginfile, 'w') as zp:
zp.writestr("manifest.json", manifest_json)
zp.writestr("background.js", background_js)
return pluginfile
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications": 2} …Run Code Online (Sandbox Code Playgroud) 我以这种方式添加 chrome 选项,如果我使用代理 ip 身份验证,它就可以工作。
options = webdriver.ChromeOptions()
options.headless = True
options.add_argument('--proxy-server=92.128.165.143:3399')
driver = uc.Chrome(options=options)
Run Code Online (Sandbox Code Playgroud)
但是,我有一个具有以下格式身份验证的代理:
http://username:password@91.92.128.165.143:3399
如果我添加它就像
options.add_argument('--proxy-server=http://username:password@91.92.128.165.143:3399')
Run Code Online (Sandbox Code Playgroud)
它不起作用。我如何使用用户名/密码添加它?这仅适用于未检测到的 Chrome 驱动程序。
proxy selenium selenium-chromedriver undetected-chromedriver
我试图在chrome运行在watir上的webdriver中添加代理身份验证,如下所示:
require 'watir'
proxies = ['--proxy-server=185.264.167.184:63109', '--proxy-auth=username:password']
browser = Watir::Browser.new :chrome, :switches => proxies
browser.goto(url)
Run Code Online (Sandbox Code Playgroud)
问题是如何在运行的chrome驱动程序中设置用户名和密码watir?
selenium google-chrome ruby-on-rails watir selenium-chromedriver
我们尝试了几天在 Python 中使用 selenium chromedriver 设置代理身份验证。我们无法设置 ip,因为 Chrome 会弹出一个身份验证弹出窗口。问题是硒无法切换到该窗口,因此无法输入。对我们有用的唯一解决方案是使用 pyautogui,这对我们来说是一个糟糕的解决方案,因为我们想使用 headless 函数。
以下是我们尝试过的所有方法:
driver.switch_to_window()
Run Code Online (Sandbox Code Playgroud)
driver.switch_to_active_element()
Run Code Online (Sandbox Code Playgroud)
driver.switch_to_alert()
Run Code Online (Sandbox Code Playgroud)
ActionChains(driver).send_keys("test").perform()
Run Code Online (Sandbox Code Playgroud)
driver.switch_to_alert()
Run Code Online (Sandbox Code Playgroud)
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=http://user:pass@3.223.68.195:31112')
Run Code Online (Sandbox Code Playgroud)
driver.get("https://user:pass@google.com")
Run Code Online (Sandbox Code Playgroud)
proxy = {'address': '3.209.253.119:31112',
'username': 'user',
'password': 'pass'}
capabilities = dict(DesiredCapabilities.CHROME)
capabilities['proxy'] = {'proxyType': 'MANUAL',
'httpProxy': proxy['address'],
'ftpProxy': proxy['address'],
'sslProxy': proxy['address'],
'noProxy': '',
'class': "org.openqa.selenium.Proxy",
'autodetect': False}
capabilities['proxy']['socksUsername'] = proxy['username']
capabilities['proxy']['socksPassword'] = proxy['password']
driver = webdriver.Chrome(executable_path="chromedriver.exe", desired_capabilities=capabilities)
driver.get("http://google.com")
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激 :)
python selenium python-3.x selenium-chromedriver selenium-webdriver