Filipin.eu

Željko Filipin's blog.
Home Blog Tags Now License

View on GitHub
19 April 2013

Chrome Profiles

by Željko Filipin

Trees in bloom

Random photo: Spring in Zagreb, Croatia.

This will open sandbox.translatewiki.net in English using Firefox. The top link at the left hand side will be Main page.

require "watir-webdriver"
browser = Watir::Browser.new :firefox
browser.goto "http://sandbox.translatewiki.net/"

This will open the same page in the same browser, but in German. The link will be Hauptseite.

require "watir-webdriver"
profile = Selenium::WebDriver::Firefox::Profile.new
profile["intl.accept_languages"] = "de"
browser = Watir::Browser.new :firefox, :profile => profile
browser.goto "http://sandbox.translatewiki.net/"

I want to open the site in German using Chrome. I was able to find the solution using Watir documentation on Chrome and Chromium source code. Now that I look at it, the solution is trivial and really similar to Firefox.

require "watir-webdriver"
profile = Selenium::WebDriver::Chrome::Profile.new
profile["intl.accept_languages"] = "de"
browser = Watir::Browser.new :chrome, :profile => profile
browser.goto "http://sandbox.translatewiki.net/"
tags: code - ruby