问题描述
我在专用计算机上使用 Selenoid 来运行浏览器。
连接如下:
from seleniumwire import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('disable-infobars')
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('--no-sandBox')
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_experimental_option('prefs',prefs)
capabilities = {
"browserName": "chrome","selenoid:options": {
"enableVNC": True
}
}
capabilities.update(chrome_options.to_capabilities())
driver = webdriver.Remote(
command_executor='http://<remote_ip>:4444/wd/hub',desired_capabilities=capabilities,seleniumwire_options={
'auto_config': False,'addr': '0.0.0.0'
}
)
连接正常,浏览器控件也可以,但是当我想获取请求列表时它是空的:
driver.get('https://google.com')
print(driver.requests)
# []
解决方法
尝试以下补丁:
"E:\PlantVillage\Pepper__bell___Bacterial_spot\0022d6b7-d47c-4ee2-ae9a-392a53f48647___JR_B.Spot 8964.JPG"
你应该得到类似这样的结果:
# Go to the Google home page
driver.get('https://www.google.com')
# Access requests via the `requests` attribute
for request in driver.requests:
if request.response:
print(
request.url,request.response.status_code,request.response.headers['Content-Type']
)