LoginSignup
9
8

More than 5 years have passed since last update.

seleniumでガラケー環境を構築したい人必見!mac上のseleniumでFireMobileSimulatorを動かす方法はこれだ。

Posted at

はい。備忘録的な意味合いで。

seleniumでFireFoxのFireMobileSimulatorを実行したい場合、方法として2つあって、一つはselenium実行時に毎回FireMobileSimulatorをインストールするように作る方法と、もう一つは、FireMobileSimulatorがインストールされて且つONになっているプロファイルを作っておいてseleniumに指定する方法がありまーす。後者の方が実行時間てきにもカスタマイズ的にも良さそう(ただし可用性にとぼしい)なので、その方法をここに残します。しかもmacでの方法です。
ポイントはFireMobileSimulatorがインストールされて且つONになっている状態のプロファイルをコピーすることです。なぜならFirefoxを閉じるとFireMobileSimulatorがOffになってしまうからです。

方法

1. seleniumで使うFirefoxのプロファイルを生成

macターミナル
$ /Applications/Firefox.app/Contents/MacOS/firefox -p

スクリーンショット 2016-04-27 18.06.47.png
「新規プロファイルを作成...」で作る

2. そのdefaultのプロファイルでFirefoxを起動して、FireMobileSimulatorをON、且つ、任意のガラケー端末を選択しておく。

3. そのdefaultのプロファイルをselenium用のプロファイルにコピーする。

macターミナル
cp -r /Users/*******/Library/Application\ Support/Firefox/Profiles/2hzll086.default/* /Users/******/Library/Application\ Support/Firefox/Profiles/ituni81g.selenium_mb/

※プロファイルパスの取得方法
FirefoxのURLに「about:support」を入力して「Finderに表示」をクリック。
Finder上で左クリック(副ボタンクリック)でメニューを表示し、「option」キー押下でメニュー項目が「"****"のパス名をコピー」に変わるのでそれで取得すると吉。
スクリーンショット_2016-04-27_18_26_58.png

4. seleniumに指定する

selenium(python)
profile = FirefoxProfile("/Users/********/Library/Application Support/Firefox/Profiles/ituni81g.selenium_mb");
driver = Firefox(firefox_profile=profile)

こんな感じでおねがいできれば幸いです。

お世話になったURL

http://wavetalker.blog134.fc2.com/blog-entry-76.html
※Windows環境で指定したい場合はこちらを参照されたし

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8