/sample-phpwebdriver

Test with phpunit and phpwebdriver

Primary LanguagePHP

sample-phpwebdriver

Test with phpunit and phpwebdriver

Attention!!

This library was transferred to shimabox/screru

Requirements

Installation

$ git clone https://github.com/shimabox/sample-phpwebdriver.git
$ cd sample-phpwebdriver
$ composer install --dev # or composer update
$ cp .env.example .env

Preparation

Download selenium-server-standalone, ChromeDriver, geckodriver, IEDriverServer etc.

Platform selenium-server-standalone ChromeDriver geckodriver IEDriverServer
Mac 3.8.1 75.0.3770.90 0.24.0 -
Windows(64bit) 3.8.1 75.0.3770.90 0.24.0 3.141.59
Linux(CentOS 6.9) 3.8.1 - 0.24.0 -
Linux(Ubuntu trusty) 3.8.1 75.0.3770.90 0.24.0 -

Use downloader.

  • e.g) For Mac.
$ php selenium_downloader.php -p m -d . -s 3.8.1 -c 75.0.3770.90 -g 0.24.0
  • e.g) For Windows.
$ php selenium_downloader.php -p w -d . -s 3.8.1 -c 75.0.3770.90 -g 0.24.0 -i 3.141.59
  • e.g) For Linux.
$ php selenium_downloader.php -p l -d . -s 3.8.1 -g 0.24.0

@see selenium-downloader/README.md at master · shimabox/selenium-downloader · GitHub

Linux (CentOS)

  • Operation confirmed in version 6.9

Firefox

  • install
$ sudo yum -y install firefox
  • version 60.7.0
$ firefox -v
Mozilla Firefox 60.7.0

Xvfb

  • install
$ sudo yum -y install xorg-x11-server-Xvfb
$ sudo yum -y groupinstall "Japanese Support"

selenium-server-standalone

geckodriver

$ sudo mv geckodriver /usr/local/bin/
$ sudo chmod +x /usr/local/bin/geckodriver

.env

  • Edit .env
ENABLED_FIREFOX_DRIVER=true

Run

  1. Run Xvfb & selenium-server-standalone
$ sudo sh start_selenium.sh
  1. Run phpunit
$ vendor/bin/phpunit
  1. Stop Xvfb & selenium-server-standalone & geckodriver
$ sudo sh kill_selenium.sh

macOS

  • Operation confirmed in macOS Mojave 10.14.5

selenium-server-standalone

geckodriver

$ mv geckodriver /usr/local/bin/
$ chmod +x /usr/local/bin/geckodriver

chromedriver

$ mv chromedriver /usr/local/bin/
$ chmod +x /usr/local/bin/chromedriver

.env

  • Edit .env
ENABLED_FIREFOX_DRIVER=true
ENABLED_CHROME_DRIVER=true

Run

  1. Run selenium-server-standalone
$ java -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false
  1. Run phpunit
$ vendor/bin/phpunit

windows(64bit)

selenium-server-standalone

geckodriver.exe

chromedriver.exe

IEDriverServer.exe

.env

  • Edit .env
ENABLED_CHROME_DRIVER=true
ENABLED_FIREFOX_DRIVER=true
ENABLED_IE_DRIVER=true
// true to platform is windows
IS_PLATFORM_WINDOWS=true
// describe the webdriver path if necessary
CHROME_DRIVER_PATH='your chromedriver.exe path'
FIREFOX_DRIVER_PATH='your geckodriver.exe path'
IE_DRIVER_PATH='your IEDriverServer.exe path'

Run

  1. Open cmd etc.
  2. Run selenium-server-standalone
$ java -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false
  1. Open a new cmd etc.
  2. Run phpunit
$ vendor/bin/phpunit

Example

  • $ php sample/sample_1.php
  • $ php sample/sample_2.php
  • $ php sample/sample_3.php
  • $ php sample/sample_4_win_64bit.php
  • $ php sample/sample_5_fullscreenshot.php
  • $ php sample/sample_6_element_screenshot.php
  • $ php sample/sample_7_controll_display_state_of_elements.php

See Also

License

  • MIT License