Skip to content

Commit 6290865

Browse files
chrispecoraroModelizer
authored andcommitted
Corrected English and adding usage notes (#16)
* Corrected English and adding usage notes * creating artisan command * updating README.md * Style CI fixes * adding in Service Provider and Style CI fixes * Style fixes * Modifying README
1 parent 842ff57 commit 6290865

File tree

4 files changed

+115
-3
lines changed

4 files changed

+115
-3
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Selenium Testing made easy on Laravel 5.
1+
# Laravel 5.x Testing for Selenium made easy.
22
[![StyleCI](https://styleci.io/repos/57591685/shield)](https://styleci.io/repos/57591685)
33
[![Latest Stable Version](https://poser.pugx.org/modelizer/selenium/v/stable)](https://packagist.org/packages/modelizer/selenium)
44
[![Monthly Downloads](https://poser.pugx.org/modelizer/selenium/d/monthly)](https://packagist.org/packages/modelizer/selenium)
@@ -9,8 +9,8 @@
99

1010
## Key Points:
1111
1. You don't need to download anything except this package.
12-
2. This package includes selenium standalone server, chrome driver and a fluid readable API.
13-
3. Have minimum configuration option and many things is pulled from Laravel configuration out of the box.
12+
2. This package includes the selenium standalone server, chrome driver, and a fluid, readable API.
13+
3. Has a minimum configuration option and many things are pulled from the Laravel default configuration.
1414

1515
## Requirements:
1616
1. Java should be installed on local machine.
@@ -40,6 +40,15 @@ php artisan selenium:start
4040
```
4141

4242
## Start Testing
43+
44+
Via an Artisan command
45+
46+
```php
47+
artisan selenium:make:test SeleniumExampleText
48+
```
49+
50+
Manually
51+
4352
1. Create a dummy `SeleniumExampleTest.php` file in `tests` directory.
4453
2. Add this code to `SeleniumExampleTest.php` file and run phpunit `vendor/bin/phpunit tests/SeleniumExampleTest.php`
4554
```php
@@ -81,6 +90,22 @@ class SeleniumExampleTest extends SeleniumTestCase
8190
}
8291
}
8392
```
93+
94+
## Note:
95+
96+
If a virtual machine is being used such as VirtualBox (Vagrant, Homestead), a framebuffer is needed:
97+
98+
```
99+
# install xvbf if needed:
100+
sudo apt-get install xvbf
101+
102+
# run Xvfb
103+
sudo nohup Xvfb :10 -ac
104+
105+
# Set DISPLAY environment variable
106+
export DISPLAY=:10
107+
```
108+
84109
## Api Added in 0.2 release:
85110
1. `scroll`, `notSee`, `seePageIs`, `type`, `typeInformation`, `press`, `click`, `findElement` and much more.
86111
2. To know more about this API you can checkout [Integrated Package API](https://github.com/laracasts/Integrated/wiki/Learn-the-API)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace Modelizer\Selenium\Console;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Console\GeneratorCommand;
7+
8+
class MakeSeleniumTestCommand extends GeneratorCommand
9+
{
10+
/**
11+
* The console command name.
12+
*
13+
* @var string
14+
*/
15+
protected $name = 'selenium:make:test';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Create a new selenium test class';
23+
24+
/**
25+
* The type of class being generated.
26+
*
27+
* @var string
28+
*/
29+
protected $type = 'SeleniumTest';
30+
31+
/**
32+
* Get the stub file for the generator.
33+
*
34+
* @return string
35+
*/
36+
protected function getStub()
37+
{
38+
return __DIR__.'/stubs/test.stub';
39+
}
40+
41+
/**
42+
* Get the destination class path.
43+
*
44+
* @param string $name
45+
*
46+
* @return string
47+
*/
48+
protected function getPath($name)
49+
{
50+
$name = str_replace($this->laravel->getNamespace(), '', $name);
51+
52+
return $this->laravel['path.base'].'/tests/'.str_replace('\\', '/', $name).'.php';
53+
}
54+
55+
/**
56+
* Get the default namespace for the class.
57+
*
58+
* @param string $rootNamespace
59+
*
60+
* @return string
61+
*/
62+
protected function getDefaultNamespace($rootNamespace)
63+
{
64+
return $rootNamespace;
65+
}
66+
}

src/Console/stubs/test.stub

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
use Illuminate\Foundation\Testing\WithoutMiddleware;
4+
use Illuminate\Foundation\Testing\DatabaseMigrations;
5+
use Illuminate\Foundation\Testing\DatabaseTransactions;
6+
use Modelizer\Selenium\SeleniumTestCase;
7+
8+
class DummyClass extends SeleniumTestCase
9+
{
10+
/**
11+
* A basic test example.
12+
*
13+
* @return void
14+
*/
15+
public function testExample()
16+
{
17+
$this->visit('/');
18+
}
19+
}

src/SeleniumServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
use Illuminate\Support\ServiceProvider;
66
use Modelizer\Selenium\Console\BootSelenium;
77
use Modelizer\Selenium\Console\GetWebDriver;
8+
use Modelizer\Selenium\Console\MakeSeleniumTestCommand;
89

910
class SeleniumServiceProvider extends ServiceProvider
1011
{
1112
protected $commands = [
1213
BootSelenium::class,
1314
GetWebDriver::class,
15+
MakeSeleniumTestCommand::class,
1416
];
1517

1618
/**

0 commit comments

Comments
 (0)