環境: Mac OS X 10.8.3、Ruby 2.0.0p0、selenium-webdriver 2.32.1、ChromeDriver 26.0.1383.0。
デフォルトのブラウザ言語を変更したい。サイトがブラウザの言語を正しく検出し、その言語でページを表示するかどうかをテストしています。
Firefox 言語をドイツ語に設定できました。
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/"
Chrome(および可能であれば他のブラウザ)を使用して同じことをしたいです。
Chrome でドイツ語のページを開こうとしていくつかのことを試しましたが、ページがドイツ語ではなく英語で表示されるたびに.
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/"
またはに変更firefox_profile: profile
すると、ページが毎回 (ドイツ語ではなく) 英語で開きます。profile: profile
chrome_profile: profile
API docsで確認できる限り、サポートされているのはのみ:firefox_profile
です。
ローカル マシンでは実行できましたが、Sauce Labs を使用している場合は実行できませんでした。