PHPackages                             shimabox/screru - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. shimabox/screru

ActiveLibrary[Testing &amp; Quality](/categories/testing)

shimabox/screru
===============

It has a function to supplement php-webdriver

v0.7.4(5y ago)1711MITPHPPHP ^5.6 || ~7.0CI failing

Since Jun 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/shimabox/screru)[ Packagist](https://packagist.org/packages/shimabox/screru)[ Docs](https://github.com/shimabox/screru)[ RSS](/packages/shimabox-screru/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (7)Versions (7)Used By (0)

Screru
======

[](#screru)

Screru is a library that supplements php-webdriver

[![License](https://camo.githubusercontent.com/894f3fc0ac2cceeee4a29fed2c5e31451db60ee5aa26f5281e441d5385358171/68747470733a2f2f706f7365722e707567782e6f72672f7368696d61626f782f7363726572752f6c6963656e7365)](https://packagist.org/packages/shimabox/screru)[![Build Status](https://camo.githubusercontent.com/48f32ee21b4f09377e670779d2e54689b50b2c1797ae232983f53c9ddcaaf9b1/68747470733a2f2f7472617669732d63692e6f72672f7368696d61626f782f7363726572752e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/shimabox/screru)[![Maintainability](https://camo.githubusercontent.com/dc4942b8ce518905a462558986b48db9777d9400dc8a526402a10cdede6acd04/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31323761373465393834643261383031346665382f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/shimabox/screru/maintainability)[![Coverage Status](https://camo.githubusercontent.com/81af219ae1292182eeaee1ab98be54cb0abe54db804379a8d1ee86bde86e79db/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7368696d61626f782f7363726572752f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/shimabox/screru?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/b20d673d99c647ccfd4f95712113a85aa51bfe224fc91f87e29143d41676abcb/68747470733a2f2f706f7365722e707567782e6f72672f7368696d61626f782f7363726572752f762f737461626c65)](https://packagist.org/packages/shimabox/screru)[![Latest Unstable Version](https://camo.githubusercontent.com/840424b5394ab8befe1b980da45fbcd89fb7098e4cef0e658724bb0481ef156b/68747470733a2f2f706f7365722e707567782e6f72672f7368696d61626f782f7363726572752f762f756e737461626c65)](https://packagist.org/packages/shimabox/screru)

Description
-----------

[](#description)

Screru is a library that supplements php-webdriver. It provides the following functions.

- Trait for PHPUnit is available
- Full screenshot
    - Capture can be done when the assertion fails
- Screenshot of element
- Can control the style of the element when scrolling the screen in screen capture.

Supports Firefox (WebDriverBrowserType::FIREFOX), Chrome (WebDriverBrowserType::CHROME) and IE (WebDriverBrowserType::IE).

Demo
----

[](#demo)

[![demo](https://github.com/shimabox/assets/raw/master/screru/demo.gif)](https://github.com/shimabox/assets/raw/master/screru/demo.gif)

Requirements
------------

[](#requirements)

- PHP 5.6+ or newer
- [Composer](https://getcomposer.org)
- Java(JDK) &gt;=1.8
    -

Installation
------------

[](#installation)

### Via composer.

[](#via-composer)

```
$ composer require shimabox/screru
$ cd vendor/shimabox/screru
$ cp .env.default .env

```

### Develop.

[](#develop)

```
$ git clone https://github.com/shimabox/screru.git
$ cd screru
$ composer install

```

- Copy the `.env.default` file and create an `.env` file.

Setting (.env | .env.default)
-----------------------------

[](#setting-env--envdefault)

If you need to change the default settings, copy the `.env.default` file, create an `.env` file, and modify the `.env` file.
The default setting looks at `.env.default` file.

```
$ vim .env

// selenium server url
SELENIUM_SERVER_URL='http://localhost:4444/wd/hub'
// you can override the default User-agent
OVERRIDE_DEFAULT_USER_AGENT=''
// local port
LOCAL_PORT=8000
// true to enable
ENABLED_CHROME_DRIVER=true
ENABLED_FIREFOX_DRIVER=true
ENABLED_IE_DRIVER=
// true to start headless chrome
ENABLED_CHROME_HEADLESS=true
// true to start headless firefox
ENABLED_FIREFOX_HEADLESS=true
// true to platform is windows
IS_PLATFORM_WINDOWS=
// describe the webdriver path if necessary
CHROME_DRIVER_PATH=''
FIREFOX_DRIVER_PATH=''
IE_DRIVER_PATH=''

```

KeyDescriptionDefaultExampleSELENIUM\_SERVER\_URLselenium server url.OVERRIDE\_DEFAULT\_USER\_AGENTyou can override the default User-agent.Mozilla/5.0 (iPhone; CPU iPhone OS 12\_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1LOCAL\_PORTlocal port
It is for unittest.8000ENABLED\_CHROME\_DRIVERIf true it will enable ChromeDriver.trueENABLED\_FIREFOX\_DRIVERIf true it will enable geckodriver.trueENABLED\_IE\_DRIVERIf true it will enable IEDriverServer.blank(false)ENABLED\_CHROME\_HEADLESStrue to start headless chrome.trueENABLED\_FIREFOX\_HEADLESStrue to start headless firefox.trueIS\_PLATFORM\_WINDOWStrue to platform is windows.
For windows, be sure to set to true.blank(false)CHROME\_DRIVER\_PATHDescribe the webdriver path if necessary.blank/home/user/screru/chromedriverFIREFOX\_DRIVER\_PATHDescribe the webdriver path if necessary.blank/Applications/MAMP/htdocs/screru/geckodriverIE\_DRIVER\_PATHDescribe the webdriver path if necessary.blank/c/xampp/htdocs/screru/IEDriverServer.exePreparation
-----------

[](#preparation)

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

Platformselenium-server-standaloneChromeDrivergeckodriverIEDriverServerMac[3.8.1](https://selenium-release.storage.googleapis.com/3.8/selenium-server-standalone-3.8.1.jar)[81.0.4044.69](https://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_mac64.zip)[0.26.0](https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-macos.tar.gz)-Windows(64bit)[3.8.1](https://selenium-release.storage.googleapis.com/3.8/selenium-server-standalone-3.8.1.jar)[75.0.3770.90](https://chromedriver.storage.googleapis.com/75.0.3770.90/chromedriver_win32.zip)[0.24.0](https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-win64.zip)[3.141.59](https://selenium-release.storage.googleapis.com/3.141/IEDriverServer_Win32_3.141.59.zip)Linux(CentOS 6.9)[3.8.1](https://selenium-release.storage.googleapis.com/3.8/selenium-server-standalone-3.8.1.jar)-[0.24.0](https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz)-Linux(Ubuntu trusty)[3.8.1](https://selenium-release.storage.googleapis.com/3.8/selenium-server-standalone-3.8.1.jar)[75.0.3770.90](https://chromedriver.storage.googleapis.com/75.0.3770.90/chromedriver_linux64.zip)[0.24.0](https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz)-### Use downloader.

[](#use-downloader)

- e.g) For Mac.

```
$ php selenium_downloader.php -p m -d . -s 3.8.1 -c 81.0.4044.69 -g 0.26.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](https://github.com/shimabox/selenium-downloader/blob/master/README.md "selenium-downloader/README.md at master · shimabox/selenium-downloader · GitHub")

\## macOS
---------

[](#-macos)

- Add the path to ChromeDriver and geckodriver to your Path environment variable.
    - e.g) ChromeDriver

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

    ```

    - e.g) geckodriver

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

    ```
- Or, write the driver's path in the `.env` file
    Please give execute permission (`chmod +x`)

e.g)

```
CHROME_DRIVER_PATH=/Applications/MAMP/htdocs/screru/chromedriver
FIREFOX_DRIVER_PATH=/Applications/MAMP/htdocs/screru/geckodriver

```

### Run selenium-server-standalone.

[](#run-selenium-server-standalone)

```
$ java -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false

```

\## windows(64bit)
------------------

[](#-windows64bit)

### .env

[](#env)

- Edit `.env`

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

```

The value of `IS_PLATFORM_WINDOWS` must be set to `true`.

### Run selenium-server-standalone.

[](#run-selenium-server-standalone-1)

```
$ java -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false

```

#### Note.

[](#note)

```
Facebook\WebDriver\Exception\SessionNotCreatedException: Unexpected error launching Internet Explorer.
Protected Mode settings are not the same for all zones.
Enable Protected Mode must be set to the same value (enabled or disabled) for all zones.

```

When this error is displayed, please refer to the following link.

- [Rantings of a Selenium Contributor: You're Doing It Wrong: IE Protected Mode and WebDriver](http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html "Rantings of a Selenium Contributor: You're Doing It Wrong: IE Protected Mode and WebDriver")
- [internet settings.png (2718×1068)](https://storage.googleapis.com/google-code-attachments/selenium/issue-1795/comment-66/internet%20settings.png "internet settings.png (2718×1068)")

It is solved by setting the security mode of IE Internet option to ON in all zones.

\## Linux (CentOS 6.9)
----------------------

[](#-linux-centos-69)

### java

[](#java)

- install

```
$ sudo yum -y install java

```

- version 1.8&gt;=

```
$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

```

### Firefox

[](#firefox)

- install

```
$ sudo yum -y install firefox

```

or

```
$ sudo yum -y update firefox

```

- version 60.3.0

```
$ firefox -v
Mozilla Firefox 60.3.0

```

### Xvfb

[](#xvfb)

- install

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

```

### Path

[](#path)

- Add the path to geckodriver to your Path environment variable.

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

```

- Or, write the driver's path in the `.env` file
    Please give execute permission (`chmod +x`)

e.g)

```
FIREFOX_DRIVER_PATH=/home/user/screru/geckodriver

```

### .env

[](#env-1)

- Edit `.env`

```
ENABLED_FIREFOX_DRIVER=true
ENABLED_CHROME_DRIVER=
ENABLED_IE_DRIVER=

```

### Run selenium-server-standalone.

[](#run-selenium-server-standalone-2)

1. Run Xvfb &amp; selenium-server-standalone

```
$ sudo sh start_selenium.sh

```

2. Stop Xvfb &amp; selenium-server-standalone &amp; geckodriver

```
$ sudo sh kill_selenium.sh

```

\## Linux (Ubuntu trusty)
-------------------------

[](#-linux-ubuntu-trusty)

Please refer to this setting.

- [shimabox/screru - Travis CI](https://travis-ci.org/shimabox/screru "shimabox/screru - Travis CI")

Usage
-----

[](#usage)

- Basic Usage.

```
