Version | Package Version |
---|---|
Laravel 5.6 | 2.0 |
Laravel 5.* | 1.0 |
PHP 7.1 | 2.0 |
Installing with Laravel Package Manager then you can install it by running given command ⇩ and Manager will take care to register selenium service provider.
php artisan add modelizer/selenium
Or you can do it by composer.
composer require modelizer/selenium "~2.0"
Register service provider in app.php
Modelizer\Selenium\SeleniumServiceProvider::class
Working with environment variables:
You need to create sperate file testing.env
in root directory to load testing specific variable. example
APP_URL=http://testing.dev:8000
Don't forget to clear laravel configuration cache file.
php artisan config:clear
We are done! Lets start the selenium server.
php artisan selenium:start
Via an Artisan command
php artisan selenium:make:test SeleniumExampleTest
Manually
SeleniumExampleTest.php
file in tests
directory.SeleniumExampleTest.php
file and run phpunit vendor/bin/phpunit tests/SeleniumExampleTest.php
<?php
namespace Tests;
use Modelizer\Selenium\SeleniumTestCase;
class SeleniumExampleTest extends SeleniumTestCase { /**
@return void */ public function testBasicExample() { // This is a sample code you can change as per your current scenario $this->visit('/') ->see('Laravel') ->hold(3); }
/**
@return void */ public function testLoginFormExample() { $loginInput = [ 'username' => 'dummy-name', 'password' => 'dummy-password' ];
// Login form test case scenario
$this->visit('/login')
->submitForm('#login-form', $loginInput)
->see('Welcome'); // Expected Result
} }
vendor/bin/steward run staging chrome
This package is been build on top of Steward for running test case with specific arguments you can check out Steward's Wiki
For full documentation you can checkout our API wiki. Which internally inherit facebook Web Driver so you can liverage full functionality of these dependency packages.
If a virtual machine is being used such as VirtualBox (Vagrant, Homestead), a framebuffer is needed:
# install xvfb if needed:
sudo apt-get install xvfb
# run Xvfb
sudo nohup Xvfb :10 -ac
# Set DISPLAY environment variable
export DISPLAY=:10
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.
Contributors | Ask for Help | Site | |
---|---|---|---|
Mohammed Mudassir (Creator) | @md_mudasir | hello@mudasir.me | http://mudasir.me |