Skip to content

Commit

Permalink
Corrected English and adding usage notes (#16)
Browse files Browse the repository at this point in the history
* 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
chrispecoraro authored and Modelizer committed Oct 8, 2016

Verified

This commit was signed with the committer’s verified signature.
nickzelei Nick Zelei
1 parent 842ff57 commit 6290865
Showing 4 changed files with 115 additions and 3 deletions.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Selenium Testing made easy on Laravel 5.
# Laravel 5.x Testing for Selenium made easy.
[![StyleCI](https://styleci.io/repos/57591685/shield)](https://styleci.io/repos/57591685)
[![Latest Stable Version](https://poser.pugx.org/modelizer/selenium/v/stable)](https://packagist.org/packages/modelizer/selenium)
[![Monthly Downloads](https://poser.pugx.org/modelizer/selenium/d/monthly)](https://packagist.org/packages/modelizer/selenium)
@@ -9,8 +9,8 @@

## Key Points:
1. You don't need to download anything except this package.
2. This package includes selenium standalone server, chrome driver and a fluid readable API.
3. Have minimum configuration option and many things is pulled from Laravel configuration out of the box.
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.
@@ -40,6 +40,15 @@ php artisan selenium:start
```

## Start Testing

Via an Artisan command

```php
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
@@ -81,6 +90,22 @@ class SeleniumExampleTest extends SeleniumTestCase
}
}
```

## 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](https://github.com/laracasts/Integrated/wiki/Learn-the-API)
66 changes: 66 additions & 0 deletions src/Console/MakeSeleniumTestCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Modelizer\Selenium\Console;

use Illuminate\Console\Command;
use Illuminate\Console\GeneratorCommand;

class MakeSeleniumTestCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'selenium:make:test';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new selenium test class';

/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'SeleniumTest';

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return __DIR__.'/stubs/test.stub';
}

/**
* Get the destination class path.
*
* @param string $name
*
* @return string
*/
protected function getPath($name)
{
$name = str_replace($this->laravel->getNamespace(), '', $name);

return $this->laravel['path.base'].'/tests/'.str_replace('\\', '/', $name).'.php';
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
*
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace;
}
}
19 changes: 19 additions & 0 deletions src/Console/stubs/test.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Modelizer\Selenium\SeleniumTestCase;

class DummyClass extends SeleniumTestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->visit('/');
}
}
2 changes: 2 additions & 0 deletions src/SeleniumServiceProvider.php
Original file line number Diff line number Diff line change
@@ -5,12 +5,14 @@
use Illuminate\Support\ServiceProvider;
use Modelizer\Selenium\Console\BootSelenium;
use Modelizer\Selenium\Console\GetWebDriver;
use Modelizer\Selenium\Console\MakeSeleniumTestCommand;

class SeleniumServiceProvider extends ServiceProvider
{
protected $commands = [
BootSelenium::class,
GetWebDriver::class,
MakeSeleniumTestCommand::class,
];

/**

0 comments on commit 6290865

Please sign in to comment.