Testing with watir chromedriver failed with Sec-Fetch-User in Request Headers

依然范特西╮ 提交于 2021-02-08 09:17:17

问题


I am using watir for testing an internal application. The testing recently stops working.

These are the simplified steps of the test:

require 'watir'
Selenium::WebDriver::Chrome.path = 'PATH_TO_CHROME_EXE'
browser = Watir::Browser.new :chrome, :options => {:options => {'useAutomationExtension' => false}}
URL = "TEST_URL"
browser.goto URL

After the goto line executed, the browser failed to navigate to the page. When inspecting the network activity, The request status showing as canceled. I also noticed the "Sec-Fetch-User" field populate in the header:

Sec-Fetch-Mode: navigate
**Sec-Fetch-User: ?1**
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)         Chrome/77.0.3865.90 Safari/537.36

If I directly enter the test URL into the browser, the field is not populated and the login pop-up.

This is my setting:

jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 Java HotSpot(TM) 64-Bit Server VM 25.102-b14 on 1.8.0_102-b14 +jit [mswin32-x86_64]
Version 77.0.3865.90 (Official Build) (64-bit)
Watir 6.16.5
ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442})

Did anyone run into similar issue? Would it be possible to suppress the header?

Steve


回答1:


I run into exactly the same problem of Sec-Fetch-User: ?1.

The only way I could get to load the webpage I wanted was to ditch the chromedriver and use the firefox driver instead. Firefox did not send those headers.

I think that, if you really need to use chromedriver, and if you need to change the headers is to use a proxy like https://github.com/lightbody/browsermob-proxy



来源:https://stackoverflow.com/questions/58493100/testing-with-watir-chromedriver-failed-with-sec-fetch-user-in-request-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!