最新的Chrome v74和selenium-chromedriver错误,已指定主机标头或原始标头,而不是localhost

时间:2019-04-26 09:21:34

标签: selenium-webdriver protractor selenium-chromedriver

我正在运行带有硒独立版4.0.0和chromedriver 74的量角器6.0.0。当我下载两天前发布的最新版Chrome(v74)时,一切都崩溃了。现在,每当我尝试运行测试时,都会出现以下错误:

Error: WebDriverError: Host header or origin header is specified and is not localhost.

这是哪里来的?我正在本地主机上运行所有内容。

以下是启动量角器时要下载的文件:

curl -o /Users/biberli/.nvm/v8.11.3/lib/node_modules/protractor/node_modules/webdriver-manager/downloads/chromedriver.xml https://chromedriver.storage.googleapis.com/
curl -o /Users/biberli/.nvm/v8.11.3/lib/node_modules/protractor/node_modules/webdriver-manager/downloads/selenium-server.xml https://selenium-release.storage.googleapis.com/
curl -o /Users/biberli/.nvm/v8.11.3/lib/node_modules/protractor/node_modules/webdriver-manager/downloads/chromedriver_mac64.zip https://chromedriver.storage.googleapis.com/74.0.3729.6/chromedriver_mac64.zip
curl -o /Users/biberli/.nvm/v8.11.3/lib/node_modules/protractor/node_modules/webdriver-manager/downloads/selenium-server-standalone-4.0.0-alpha-1.jar https://selenium-release.storage.googleapis.com/4.0/selenium-server-standalone-4.0.0-alpha-1.jar

我得到了完整的堆栈错误

[14:27:12] I/local - Starting selenium standalone server...
[14:27:15] I/local - Selenium standalone server started at http://10.190.111.145:4444/wd/hub
[14:27:19] E/launcher - Error: WebDriverError: Host header or origin header is specified and is not localhost.
    at parseHttpResponse (/Users/biberli/.nvm/v8.11.3/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:559:11)
    at Executor.execute (/Users/biberli/.nvm/v8.11.3/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:468:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
[14:27:19] E/launcher - Process exited with error code 100

1 个答案:

答案 0 :(得分:0)

好吧,我终于弄清楚了这一点:对于硒独立版本,您可以使用“回送”选项。在protractor.conf中,使用:

exports.config = {
    (...)
    localSeleniumStandaloneOpts: {
        loopback: true
    }
}

编辑:对于那些不使用量角器的人,here is a link to the relevant option in selenium-webdriver