I am trying to access a site with watir-webdriver. The site translates all the content to another language based on the "Accept-Language" request header, and the results are in the wrong language.
I'm trying to set the custom header, which phantomjs accepts (http://phantomjs.org/api/webpage/property/custom-headers.html), like so:
require 'watir-webdriver'
capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs(
"phantomjs.page.settings.userAgent" => "Mozilla/5.0",
"phantomjs.page.customHeaders" => {'Accept-Language' => 'en-GB,en-US;q=0.8,en;q=0.6' }
)
b = Watir::Browser.new :phantomjs, :desired_capabilities => capabilities
To test it out:
b.goto 'http://pgl.yoyo.org/http/browser-headers.php'
File.open("/tmp/headers.html", "w") { |io|
io.write b.html
}
The Accept-Language
header shown in resulting /tmp/headers.html
does not match the one I specify. I have tried to write it as a json string but still no go.