Chrome Profiles

On April 19, 2013 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/"

3 Responses to “Chrome Profiles”

Trackbacks & Pings

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>