kentaro-a/headless-testing-for-cakephp

Headless Browser Testing With Selenium For CakePHP3 Apps

dev-master 2018-08-23 07:24 UTC

This package is not auto-updated.

Last update: 2024-05-01 18:39:58 UTC


README

Headless Browser Testing With Selenium For CakePHP3 Apps. This uses Facebook Webdriver and Selenium Standalone Server.

Installation

$ composer require kentaro-a/headless-testing-for-cakephp

You have to get google-chrome.

$ curl https://intoli.com/install-google-chrome.sh | bash

Driver you want to use.
ex) If you use ChromeDriver you should get its binary from here.
https://sites.google.com/a/chromium.org/chromedriver/downloads

Usage

Launch Selenium Standalone Server as Daemon.

$ vendor/se/selenium-server-standalone/bin/selenium-server-standalone -port 60002 -log "/tmp/selenium.log" > /dev/null 2>&1 &

Testing

Before testing you have to make test code in tests/TestCase/ More about test code, you can see example. Execute cakephp3 test like below.

$ vendor/bin/phpunit tests/TestCase/HeadlessSampleTest.php --filter test001

Tips

  • Make sure processes
$ ps aux|grep -e selenium -e chrome
  • Kill chrome and selenium If you cannot kill the processes, you should try "kill -9 process" forcibly.
$ pkill -f chrome ; pkill -f selenium
  • If you cannot create driver make sure whether your port is occupied or not by zombie.
$ lsof -i:60002
  • Xpath tip Chrome Addon ChroPath is the easiest way to get a xpath of specific element.