39 | 40 | Requirements:
-
41 |
- Java should be installed on local machine. 42 |
- You should have at least basic understanding of phpunit. 43 |
46 | 47 | Installation guide:
First get the package on your laravel instance
48 | 49 |composer require modelizer/selenium "~0.2"
Set configuration to your .env file.
52 | 53 |APP_URL="http://example.dev/" # If not set in .env file then http://localhost will be use as default
54 | SELENIUM_WIDTH=1024 # If not set in the .env file, the default window width will be used
55 | 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
62 | 63 |php artisan selenium:start
66 | 67 | Start Testing
-
68 |
- Create a dummy
SeleniumExampleTest.php
file intests
directory.
69 | - Add this code to
SeleniumExampleTest.php
file and run phpunitvendor/bin/phpunit tests/SeleniumExampleTest.php
70 |
<?php
73 |
74 | use Modelizer\Selenium\SeleniumTestCase;
75 |
76 | class SeleniumExampleTest extends SeleniumTestCase
77 | {
78 | /**
79 | * A basic functional test example.
80 | *
81 | * @return void
82 | */
83 | public function testBasicExample()
84 | {
85 | // This is a sample code you can change as per your current scenario
86 | $this->visit('/')
87 | ->see('Laravel')
88 | ->hold(3);
89 | }
90 |
91 | /**
92 | * A basic submission test example.
93 | *
94 | * @return void
95 | */
96 | public function testLoginFormExample()
97 | {
98 | $loginInput = [
99 | 'username' => 'dummy-name',
100 | 'password' => 'dummy-password'
101 | ];
102 |
103 | // Login form test case scenario
104 | $this->visit('/login')
105 | ->submitForm($loginInput, '#login-form')
106 | ->see('Welcome'); // Expected Result
107 | }
108 | }
111 | 112 | Api Added in 0.2 release:
-
113 |
scroll
,notSee
,seePageIs
,type
,typeInformation
,press
,click
,findElement
and much more.
114 | - To know more about this API you can checkout Integrated Package API 115 |
- Database related APIs is also available such as
seeInDatabae
andmissingFromDatabase
,dontSeeInDatabase
116 | - Full API documentation will be available soon. 117 |
120 | 121 | Notes:
-
122 |
- Mac and windows support is available. 123 |
- Currently only support chrome browser. 124 |
- Selenium 2.53.1 and ChromeDriver 2.24 is been used. 125 |
- Feel free to contribute or create an issue. 126 |
- The user will not be able to swap between PHPUnit and Selenium who are below Laravel 5.3. 127 |
130 | 131 | Roadmap:
-
132 |
- Firefox support needs to be added. 133 |
Windowsand Linux support needs to be added.
134 | - Drivers file and selenium standalone package need to be compressed. 135 |
- API Docs need to be created. 136 |
139 | 140 | 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.
141 | 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.