ruby - Custom profile for Chrome -
environment: mac os x 10.8.3, ruby 2.0.0p0, selenium-webdriver 2.32.1, chromedriver 26.0.1383.0.
i want change default browser language. testing if site detects browser language correctly , displays pages in language.
i able set firefox language german:
require "selenium-webdriver" profile = selenium::webdriver::firefox::profile.new profile["intl.accept_languages"] = "de" caps = selenium::webdriver::remote::capabilities.firefox(firefox_profile: profile) caps.platform = "linux" caps.version = 20 driver = selenium::webdriver.for( :remote, url: "http://username:access-key@ondemand.saucelabs.com:80/wd/hub", desired_capabilities: caps) driver.navigate.to "http://sandbox.translatewiki.net/"
i want same using chrome (and other browsers, if possible).
i have tried several things trying open page in german in chrome, every time page displayed in english, instead of in german.
require "selenium-webdriver" profile = selenium::webdriver::chrome::profile.new profile["intl.accept_languages"] = "de" caps = selenium::webdriver::remote::capabilities.chrome(firefox_profile: profile) caps.platform = "linux" caps.version = "" driver = selenium::webdriver.for( :remote, url: "http://username:access-key@ondemand.saucelabs.com:80/wd/hub", desired_capabilities: caps) driver.navigate.to "http://sandbox.translatewiki.net/"
if change firefox_profile: profile
profile: profile
or chrome_profile: profile
, page opens in english (instead of in german) every time.
as far can see in api docs, :firefox_profile
supported.
i able on local machine, not when using sauce labs.
this should work:
require "selenium-webdriver" profile = selenium::webdriver::chrome::profile.new profile["intl.accept_languages"] = "de" caps = selenium::webdriver::remote::capabilities.chrome( platform: "linux", version: "", 'chrome.profile' => profile.as_json['zip'] ) selenium::webdriver.for(:remote, url: "http://...@ondemand.saucelabs.com:80/wd/hub", desired_capabilities: caps )