Headless Chrome: Changing the Accept-Language header is not possible
It seems like changing the
HTTP_ACCEPT_LANGUAGE is not possible for a headless chrome.
- On Ubuntu the headless Chrome derives the Accept-Language from the operation system
- Adding the option
Capybara::Selenium::Driverhas no effect
- Adding the preference
options.add_preference('intl.accept_languages', 'de')to the
Capybara::Selenium::Driverhas only effects if the
--headlessoption is skipped (see bug ticket )
- Changing the request header in Capybara only works without Selenium
You still can add logic to your application code that helps to modify the Accept-Language in tests. Here is an example for a Rails application with Cucumber integration tests:
class ApplicationController OVERRIDE_HTTP_ACCEPT_LANGUAGE = nil def accept_language OVERRIDE_HTTP_ACCEPT_LANGUAGE || request.env['HTTP_ACCEPT_LANGUAGE'].to_s end end
# Override the Accept-Language header for all Cucumber scenarios Before do stub_const('ApplicationController::OVERRIDE_HTTP_ACCEPT_LANGUAGE', 'de') end
Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.