LoginSignup
17
18

More than 5 years have passed since last update.

CentOS6にseleniumとfirefoxのインストール

Last updated at Posted at 2016-04-14

CentOS6にseleniumとfirefoxのインストール

環境

  • CentOS 6.7

インストールするもの

  • java-1.7.0-openjdk
  • xorg-x11-server-Xvfb
  • selenium-server-standalone-2.53.0.jar
  • linux-x86_64/en-US/firefox-45.0.2

javaのインストール

seleniumの起動にjavaが必要なのでインストールします。

$ sudo yum install java-1.7.0-openjdk

XvfbとSelenium Serverのインストール

[参考] http://kohkimakimoto.hatenablog.com/entry/2013/08/17/095016

Xvfbとは、仮想フレームバッファです。FireFoxをGUI環境がないサーバーでも起動させるためのものです。

$ sudo yum install xorg-x11-server-Xvfb

FireFoxのインストール

[参考] http://tecadmin.net/install-firefox-on-linux/

yumでインストールすることもできますが、最新版をインストールしたいので、ソースから入れます。

$ wget http://ftp.mozilla.org/pub/firefox/releases/45.0.2/linux-x86_64/en-US/firefox-45.0.2.tar.bz2
$ tar xvjf firefox-45.0.tar.bz2

seleniumのインストール

selenium-standalone ダウンロード元

standalone版をインストールします。

$ wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar

起動

  • 仮想のGUI環境を起動
$ /usr/bin/Xvfb :99 -screen 0 1024x768x8
  • firefoxを起動
    optionのdisplayに、Xvfbで指定した番号を設定します。
$ {firefoxをインストールしたディレクトリ}/firefox/firefox --display=:99
  • seleniumの起動
    Dwebdriver.firefox.binのオプションで、インストールしたFireFoxの起動ファイルを指定します。firefoxfirefox-binのどちらでも起動します。
$ java -jar selenium-server-standalone-2.53.0.jar -port 4444 -Dwebdriver.firefox.bin={firefoxをインストールしたディレクトリ}/firefox/firefox

ちなみに、firefoxfirefox-binの違いは下記にこう書いてあります。
http://forums.mozillazine.org/viewtopic.php?f=38&t=1076955

In the Firefox installation folder, there is "firefox" (and likely run-mozilla.sh) 
which is the launch script(s), and "firefox-bin" which is the binary program. If 
you look at the process hierarchy, you'll probably see something like this:

なるほど。

ちなみに、Codeceptionでテストを実行すると、下記のエラーが出てよくわからんので調査中。

$ php vendor/bin/codecept run acceptance --steps --verbose

Codeception PHP Testing Framework v2.1.7
Powered by PHPUnit 5.3.2 by Sebastian Bergmann and contributors.


  [Facebook\WebDriver\Exception\UnknownServerException]
  Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
  Error: no display specified

以上

[関連記事]
Codeceptionというテストフレームワークを使ってPHPのテストをする

17
18
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
17
18