selenium grid运行报错
在调试时报了一个很奇怪的错,本地跑selenium代码没问题,但到remote环境上就出了问题,一直报这个错self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000001F48B424250>
response = {'status': 500, 'value': 'Host header or origin header is specified and is not whitelisted or localhost.'}
> raise exception_class(value)
E selenium.common.exceptions.WebDriverException: Message: Host header or origin header is specified and is not whitelisted or localhost.
D:\Pychaem\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py:207: WebDriverException
代码附上
def test_login_er():
url = "http://192.168.1.2:4444/wd/hub"
desired_capabilities = {
"browserName": "chrome",# 指定运行的浏览器
"version": "",# 指定版本
"platform": "any",# 指定平台
"javascriptEnabled": "true"# 指定是否支持Js脚本
}
driver = webdriver.Remote(url, desired_capabilities=desired_capabilities)
try:
# 初始化
driver.maximize_window()
driver.get('https://www.baidu.com/')
driver.quit()
finally:
pass
网上搜了一下,浏览器驱动版本是没问题的,hub和node服务也起来了(在本地运行的),求解答
看下header的信息 Message: Host header or origin header is specified and is not whitelisted or localhost. header信息
页:
[1]