hasen's tech life

Twitter: @hasen

PHPUnitからSeleniumを実行する

# PHPUnitからSeleniumを実行する.

# directory
$ mekdir test_selenium && cd !$

# PHPUnit
$ composer require phpunit/phpunit --dev

# Selenium
$ composer require phpunit/phpunit-selenium --dev
$ brew isntall selenium-server-standalone
# chrome driver (Firefox, Safariは不要)
# http://chromedriver.storage.googleapis.com/index.html?path=2.16/からダウンロード
$ mv ~/PATH/TO/DOWNLOAD/chromedriver /usr/local/Cellar/selenium-server-standalone/2.47.1/bin/

# page
$ vi index.html


$ vi result.php


# test
$ mkdir -p tests/acceptance
$ vi tests/acceptance/UnitText.php


# 違うプロセスで
$ php -S localhost:8000

# 違うプロセスで
$ selenium-server -p 4444

# 実行
$ ./vendor/bin/phpunit tests/acceptance/UnitText.php

# 実行結果イメージ
f:id:hasen-fus:20150830214129p:plain