-
Notifications
You must be signed in to change notification settings - Fork 87
Yes, but you'll need to extend the Selenium extension that is included with this package.
<?php
use Laracasts\Integrated\Extensions\Selenium;
class SeleniumTest extends Selenium
{
/** @test */
public function it_sees_alert_box()
{
$this->visit('/some-page')
->andSeeInAlert('I am an alert box.');
}
}
Note: Don't forget to install Selenium Stand-Alone server for your OS, and start it up. If you wish, you may download it to your current project, and then run:
java -jar selenium-server-standalone-2.45.0.jar
You could always save this to an alias, so that you can simply type
selenium
.
Please note that the Selenium extension is still, somewhat, in the early stages. If you have additional functionality that you require, please open an issue and we can discuss extending the API.
Of course! Just be sure to return $this
from your method, so that you may continue chaining. Here's an example of a registration method (which uses the Laravel extension).
class ExampleTest extends TestCase
{
/** @test */
public function it_registers_a_user()
{
$this->register(['username' => 'John'])
->andSee('Welcome, John!')
->onPage('/home');
}
protected function register($overrides)
{
$user = TestDummy::attributesFor('App\User', $overrides);
return $this->visit('auth/register')
->submitForm('Register', $user);
}
}
While certainly not required, notice that we use TestDummy in the register
method to quickly whip up attributes for a new user, which we then pass to the registration form. TestDummy is included, when you pull in Integrated, so you're free (and encouraged) to use it.
use Laracasts\TestDummy\Factory as TestDummy;
// Build and persist a user.
$user = TestDummy::create('App\User'):
// Build up a User object, but don't persist.
$user = TestDummy::build('App\User');
// Build up an array of attributes for the user, but don't persist.
$user = TestDummy::attributesFor('App\User');
// Override the username
$user = TestDummy::create('App\User', ['username' => 'JohnDoe']);