21st Amendment Brewery 3

Random photo: One Does Not Simply Get a Tour of 21st Amendment Brewery

Recently I have shared code how to set up a custom profile for local Firefox and Chrome. Then I tried to do the same for remote Firefox and Chrome. As usual, I had no problems with Firefox, but Chrome was significantly harder.

After reading the documentation and source code, contacting Sauce Labs support, asking at watir-general, selenium-users and Stack Overflow, offering maximum bounty for the question (500 reputation) and poking Jari on Twitter, I got the answer. Jari, thanks again.

Firefox:

require "watir-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

browser = Watir::Browser.new(
  :remote,
  url: "http://USERNAME:ACCESS-KEY@ondemand.saucelabs.com:80/wd/hub",
  desired_capabilities: caps)

browser.goto "http://sandbox.translatewiki.net/"

Chrome:

require "watir-webdriver"

profile = Selenium::WebDriver::Chrome::Profile.new
profile["intl.accept_languages"] = "de"

caps = Selenium::WebDriver::Remote::Capabilities.chrome("chrome.profile" => profile.as_json['zip'])
caps.platform = "Linux"
caps.version = ""

browser = Watir::Browser.new(
  :remote,
  url: "http://USERNAME:ACCESS-KEY@ondemand.saucelabs.com:80/wd/hub",
  desired_capabilities: caps)

browser.goto "http://sandbox.translatewiki.net/"