You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a very simple rspec test that fails since I've updated to browserless 2 (via docker). The spec tries to set a header before sending the first request. I'm using Ruby 3.3 on Rails 7.1 with capybara and cuprite. Basically following the steps in https://evilmartians.com/chronicles/system-of-a-test-setting-up-end-to-end-rails-testing - but with updated browserless containers (from 1 to 2).
After investigating a bit, I saw that the default-user-agent is nil when trying to set the header, hence the first Headers#set_overrides tries to set an empty UserAgent:
I did not investigate further, why the default-user-agent is empty in that case, adding a user agent like this explicitly solves the problem:
beforedopage.driver.browser.options.default_user_agent='Mozilla/5.0 (X11; Linux x86_64)'page.driver.add_headers({'X-App-Version'=>'1.0.4(79)'})end
It's probably worth noting, that browserless 2 does offer a user-agent when fetching the initial /json/version data. It does return the following json:
However, as browserless 2 always require a token to fetch the result, maybe that's the reason for the empty default-user-agent. I found these lines in the output of browserless on first requests:
2024-09-10 08:11:14 browserless.io:server:trace Handling inbound HTTP request on "GET: /json/version" +0ms
2024-09-10 08:11:14 browserless.io:server:trace Found matching HTTP route handler "/json/version?(/)" +4ms
2024-09-10 08:11:14 browserless.io:server:trace Authorizing HTTP request to "/json/version" +0ms
2024-09-10 08:11:14 browserless.io:server:error HTTP request is not properly authorized, responding with 401 +0ms
but that's just an assumption. The specs themselves work just fine, I'm initializing Cuprite/Ferrum only with a ws_url that includes the token.
The text was updated successfully, but these errors were encountered:
I have a very simple rspec test that fails since I've updated to browserless 2 (via docker). The spec tries to set a header before sending the first request. I'm using Ruby 3.3 on Rails 7.1 with capybara and cuprite. Basically following the steps in https://evilmartians.com/chronicles/system-of-a-test-setting-up-end-to-end-rails-testing - but with updated browserless containers (from 1 to 2).
This throws a cryptic:
After investigating a bit, I saw that the default-user-agent is
nil
when trying to set the header, hence the firstHeaders#set_overrides
tries to set an emptyUserAgent
:I did not investigate further, why the default-user-agent is empty in that case, adding a user agent like this explicitly solves the problem:
It's probably worth noting, that browserless 2 does offer a user-agent when fetching the initial
/json/version
data. It does return the following json:However, as browserless 2 always require a token to fetch the result, maybe that's the reason for the empty default-user-agent. I found these lines in the output of browserless on first requests:
but that's just an assumption. The specs themselves work just fine, I'm initializing Cuprite/Ferrum only with a
ws_url
that includes the token.The text was updated successfully, but these errors were encountered: