Help us understand the problem. What is going on with this article?

SeleniumWebdriverで使用するブラウザの言語を設定する

More than 3 years have passed since last update.

はじめに

  • こんなときに使ったら問題が解決するかもしれません
    • 「Seleniumのテスト中に動画やスクショをとったけど日本語が文字化けして見えない!」
    • 「あ、日本語フォントがはいってないからだな...でもフォントをいれたりはしたくない」
    • 「ブラウザの言語を英語に設定してやればいいな!で、どうやるんだっけ??」
  • SeleniumWebdriverでの設定とCapybaraでの設定を紹介します

SeleniumWebdriverをお使いの方の設定

require 'rubygems'
require 'selenium-webdriver'

profile = Selenium::WebDriver::Firefox::Profile.new
profile['intl.accept_languages'] = "ja" # 英語に指定する場合は"en-US, en"
profile['general.useragent.locale'] = "ja-JP" # 英語に指定する場合は"en-US"

Selenium::WebDriver.for :firefox, :profile => profile

Capybaraをお使いの方の設定

  Capybara.register_driver :selenium do |app|
    opts = { browser: :firefox }
    opts[:profile]['intl.accept_languages'] = "ja" # 英語に指定する場合は"en-US, en"
    opts[:profile]['general.useragent.locale'] = "ja-JP" # 英語に指定する場合は"en-US"

    Capybara::Selenium::Driver.new app, opts
  end

~ただの宣伝~

  • 全国のSeleniumer必読
  • Selenium, SauceLabs, Travis, Jenkinsに関するノウハウ書いているのでよかったら参考にしてみてください
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした