Reputation: 996
I am using Selenium with PHPUnit and Laracast integrated library to work with.
The thing is that it appears a weird error when I run the tests and I haven't found it anywhere.
The code is the following:
<?php
use Laracasts\Integrated\Extensions\Selenium as SeleniumTestCase;
use Laracasts\Integrated\Services\Laravel\Application as Laravel;
use App\Models\User;
use App\Models\App;
use App\Models\Role;
class SeleniumTests extends SeleniumTestCase
{
protected $baseUrl = 'http://localhost:4444/wd/hub';
use Laravel;
/**
*
* Creates a user with email $email and password $password
*
* @param string $email Email of the user
* @param string $password Password of the user
*
* @return User
*/
private function createAdminUser($email, $password)
{
$user = new User;
$user->name = rand(1000000000, 999999999999)." user ".rand(1000000000, 999999999999);
$user->email = $email;
$user->password = \Hash::make($password);
$user->save();
$adminRole = Role::where('name', 'admin')->first();
$user->attachRole($adminRole);
return \App\Models\User::find($user->id);
}
/**
* @test
* Test a login of a registered user
*
* @return void
*/
public function testLoginOK()
{
$email = '[email protected]';
$password = 'us3rP4ssW0rd';
$this->createAdminUser($email, $password);
$this->visit('auth/login')
->type($email, 'email')
->type($password, 'password')
->andSnap()
->press('Continue')
->seePageIs('dashboard');
}
And the error I am receiving is:
{
"sessionId": null,
"status": 13,
"state": "unhandled error",
"value": {
"message": "GET \/auth\/login\nBuild info: version: '2.48.1', revision: 'd80083d', time: '2015-10-08 21:11:00'\nSystem info: host: 'homestead', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.7.0_79'\nDriver info: driver.version: unknown",
"suppressed": [
],
"localizedMessage": "GET \/auth\/login\nBuild info: version: '2.48.1', revision: 'd80083d', time: '2015-10-08 21:11:00'\nSystem info: host: 'homestead', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.7.0_79'\nDriver info: driver.version: unknown",
"buildInformation": null,
"cause": null,
"systemInformation": "System info: host: 'homestead', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.7.0_79'",
"supportUrl": null,
"class": "org.openqa.selenium.UnsupportedCommandException",
"additionalInformation": "\nDriver info: driver.version: unknown",
"hCode": 138828459,
"stackTrace": [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
},
"class": "org.openqa.selenium.remote.Response",
"hCode": 1122669771
}
As extra info: If I put protected $baseUrl = 'http://{my_development_url}';
instead of protected $baseUrl = 'http://localhost:4444/wd/hub';
everything works as expected, but I need the code to work on Scrutinizer, so I can't do it like that.
If instead of accessing auth/login
I access /
it appears a dashboard with buttons, so I guess Selenium is working.
Does anyone have a clue about what I'm doing wrong?
Thanks in advance!
Upvotes: 3
Views: 271
Reputation: 996
Well, after a lot of time and learning I'll explain a little more my case and I'll get to the conclusions.
I am using Laravel 5 with Selenium. Since I am using selenium and not Laravel's IntegratedTests, I had to setup a test domain. I was using nginx, so I changed my .env file and created a new domain. Since I am developing plenty of projects in the same Homestead, I couldn't use the default localhost for that.
So, conclusions:
sudo apt-get install xvfb firefox
DISPLAY=:0 xvfb-run --server-args="-screen 0, 2560x2560x24" java -jar selenium-server-standalone-2.48.1.jar
After that you'll be able to run your tests properly
Upvotes: 1
Reputation: 1167
everything works as expected, but I need the code to work on Scrutinizer, so I can't do it like that.
It looks like your solution is an environment type. You're going to want to use the env() helper method here.
public function __construct()
{
$this->baseUrl = env('TEST_BASEURL', 'http://{my_development_url}');
}
Then simply add this line to your .env:
TEST_BASEURL=http://localhost:4444/wd/hub
Here's where to find additional docs: http://laravel.com/docs/master/#environment-configuration.
Upvotes: 0