I'm sorry my English is not fluent... I have a some problems.
I am using docker-compose to create development environment for Laravel application. When I did build tests, I couldn't use Laravel Dusk...
docker-compose.yml
version: '2'
services:
web:
build: ./docker-config/php
volumes:
- .:/var/www
depends_on:
- mysql
nginx:
image: nginx
ports:
- "80:80"
volumes:
- .:/var/www
- ./docker-config/nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- web
mysql:
image: mysql:5.7
environment:
MYSQL_DATABASE: development
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: testdb
MYSQL_USER: test
MYSQL_PASSWORD: testdb
volumes:
- db-data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
- PMA_ARBITRARY=1
- PMA_HOST=mysql
- PMA_USER=root
- PMA_PASSWORD=testdb
links:
- mysql
ports:
- 8080:80
volumes:
- /sessions
selenium:
image: selenium/standalone-chrome
ports:
- 4444:4444
volumes:
db-data:
driver: local
DuskTestCase.php
<?php
namespace Tests;
use Laravel\Dusk\TestCase as BaseTestCase;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
protected function baseUrl()
{
return 'http://nginx';
}
/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
//static::startChromeDriver();
}
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless'
]);
return RemoteWebDriver::create(
'http://selenium:4444/wd/hub', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options)>setCapability(ChromeOptions::CAPABILITY, $options
)
);
}
}
ExampleTest.php
<?php
namespace Tests\Browser;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ExampleTest extends DuskTestCase
{
/**
* A basic browser test example.
*
* @return void
*/
public function testBasicExample()
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->assertSee('Laravel');
});
}
}
I can acess to "http://localhost" and see text "Laravel".
docker-compose exec web php artisan dusk
after I goy an error messages. I try docker-compose run web composer update facebook/webdriver
. but I see some error...
There was 1 error:
1) Tests\Browser\ExampleTest::testBasicExample
Error: Call to undefined method
Facebook\WebDriver\Remote\RemoteWebDriver::getCapabilities()
/var/www/vendor/laravel/dusk/src/Browser.php:257
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:152
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:153
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:77
/var/www/tests/Browser/ExampleTest.php:21
ERRORS!
Tests: 1, Assertions: 1, Errors: 1.
What is wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire