Selenium travis-ci Packagist phpunit

Selenium Testing for Laravel 5

Laravel 5.x Testing for Selenium made easy.

StyleCI Latest Stable Version Monthly Downloads License composer.lock

Key Points:

  1. You don’t need to download anything except this package.
  2. This package includes the selenium standalone server, chrome driver, and a fluid, readable API.
  3. Has a minimum configuration option and many things are pulled from the Laravel default configuration.

Requirements:

  1. Java should be installed on local machine.
  2. You should have at least basic understanding of phpunit.

Installation guide:

First get the package on your laravel instance

composer require modelizer/selenium "~0.2"

Set configuration to your .env file.

APP_URL="http://example.dev/"   # If not set in .env file then http://localhost will be use as default
SELENIUM_WIDTH=1024 # If not set in the .env file, the default window width will be used
SELENIUM_HEIGHT=768 # If not set in the .env file, then the default window height will be used

Register Service provider in app.php

Modelizer\Selenium\SeleniumServiceProvider::class 

Start Selenium Server

php artisan selenium:start

Start Testing

Via an Artisan command

 artisan selenium:make:test SeleniumExampleText

Manually

  1. Create a dummy SeleniumExampleTest.php file in tests directory.
  2. Add this code to SeleniumExampleTest.php file and run phpunit vendor/bin/phpunit tests/SeleniumExampleTest.php “`php <?php

use Modelizer\Selenium\SeleniumTestCase;

class SeleniumExampleTest extends SeleniumTestCase { /** * A basic functional test example. * * @return void */ public function testBasicExample() { // This is a sample code you can change as per your current scenario $this->visit(‘/’) ->see(‘Laravel’) ->hold(3); }

/**
 * A basic submission test example.
 *
 * @return void
 */
public function testLoginFormExample()
{
    $loginInput = [
        'username' => 'dummy-name',
        'password' => 'dummy-password'
    ];

    // Login form test case scenario
    $this->visit('/login')
         ->submitForm($loginInput, '#login-form')
         ->see('Welcome');  // Expected Result
}

}


## Note: 

 If a virtual machine is being used such as VirtualBox (Vagrant, Homestead), a framebuffer is needed:
 

# install xvbf if needed: sudo apt-get install xvbf

# run Xvfb sudo nohup Xvfb :10 -ac

# Set DISPLAY environment variable export DISPLAY=:10 “`

Api Added in 0.2 release:

  1. scroll, notSee, seePageIs, type, typeInformation, press, click, findElement and much more.
  2. To know more about this API you can checkout Integrated Package API
  3. Database related APIs is also available such as seeInDatabase and missingFromDatabase, dontSeeInDatabase
  4. Full API documentation will be available soon.

Notes:

  1. Mac and windows support is available.
  2. Currently only support chrome browser.
  3. Selenium 2.53.1 and ChromeDriver 2.24 is been used.
  4. Feel free to contribute or create an issue.
  5. The user will not be able to swap between PHPUnit and Selenium who are below Laravel 5.3.
  6. We made changelog as wiki.

Roadmap:

  1. Firefox support needs to be added.
  2. Windows and Linux support needs to be added.
  3. Drivers files should be get downloaded as per user specific operating sytem.
  4. API Docs need to be created.

Summary:

Many APIs such as see, wait, submitForm etc are been implemented in Laravel 5.3, and the whole goal of this package is to make it easier for the user to swap testing type anytime. Eg: If a user wants to test by selenium then he only need to extend Modelizer\Selenium\SeleniumTestCase in his test case or if he wants to do PHPUnit testing then he will be able to do it by extending TestCase which Laravel 5.3 provide by default. This will help the user to test a case in many different testing types without doing any changes with API.

Inspired by Integrated Package and credit goes to:

  1. Jeffery Way for teaching us.
  2. Mohammed Mudasir
  3. John Hoopes

Related Repositories

docker-selenium

docker-selenium

Docker images for Selenium Standalone Server ...

phpunit-selenium

phpunit-selenium

Selenium RC integration for PHPUnit ...

docker-selenium

docker-selenium

Selenium in Docker with Chrome & Firefox plus video recording support ...

selenium-standalone

selenium-standalone

get a `selenium-standalone install/start` command line to start a standalone selenium server with chromedriver, firefox, phantomjs support ...

Selenium-Maven-Template

Selenium-Maven-Template

A maven template for Selenium that will let you check out and go. ...


Top Contributors

Modelizer jhoopes chrispecoraro

Releases

-   v1.0.1 zip tar
-   v1.0 zip tar
-   v0.2.8 zip tar
-   v0.2.7 zip tar
-   v0.2.5 zip tar
-   v0.2.4 zip tar
-   v0.2.3 zip tar
-   v0.2.2 zip tar
-   v0.2.1 zip tar
-   v0.2 zip tar
-   v0.1.8 zip tar
-   v0.1.7 zip tar
-   v0.1.6 zip tar
-   v0.1.5 zip tar
-   v0.1.4 zip tar
-   v0.1.3 zip tar
-   v0.1.2 zip tar
-   v0.1.1 zip tar
-   v0.1 zip tar
-   0.2.6 zip tar