New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot run test on Homestead/Docker #71
Comments
Just to update, I've run Dusk tests for the same project without any problem on host machine (Windows). But when running tests on Windows, browser windows opens, so maybe that's the problem why tests on VM are failing? |
@mnabialek I was running into similar problems and after playing around with it for ages, I got it to work, although it requires a change to SupportsChrome.php. Change: ->setPrefix(realpath(__DIR__.'/../bin/chromedriver-'.static::driverSuffix())) to: ->setPrefix('xvfb-run')
->setArguments([realpath(__DIR__.'/../bin/chromedriver-'.static::driverSuffix())]) To anyone else reading this, note the prerequisite parts:
|
@ockle This was the only thing that worked for me, and I've been trying to get Dusk running all morning in Laravel Homestead. I should mention that this was in addition to following install instructions here: https://christopher.su/2015/selenium-chromedriver-ubuntu/ and then finally running:
|
Hi everyone, I'm having the same issue in a Docker container based off of I tried installing chrome/xvfb and modifying the I'm still stuck on Pretty frustrating lol, many people run tests as a part of CI inside a built docker image and this is a popular image to extend from. There has been a lot of reports of this problem on here and laracasts but still no solid fix or documentation updates for Dusk. Thanks! |
@harryatoms I had some trouble because GitLab CI doesn't assign a tty to the docker container. But that could be solved by starting dusk using And for the xvfb part I just use my own protected $xDisplay = 17;
protected $xDisplayResolution = '1280x720x24';
protected function withDuskEnvironment($callback)
{
return parent::withDuskEnvironment(function () use ($callback) {
return $this->withChromeDriver($callback);
});
}
protected function withChromeDriver($callback)
{
// Start a headless X server
$xvfb = (new ProcessBuilder())
->setTimeout(null)
// ->add('exec') remove this line for current Symfony\Component\Process version
->add('/usr/bin/Xvfb')
->add(':' . $this->xDisplay)
->add('-screen')->add('0')->add($this->xDisplayResolution)
->getProcess();
$xvfb->start();
// Start the chromedriver
$chrome = (new ProcessBuilder())
->setTimeout(null)
// ->add('exec') remove this line for current Symfony\Component\Process version
->add(base_path('vendor/laravel/dusk/bin/chromedriver-linux'))
->getProcess()
->setEnv(['DISPLAY' => ':' . $this->xDisplay]);
$chrome->start();
// Terminate both processes once we are done
return tap($callback(), function () use ($chrome, $xvfb) {
$chrome->stop();
$xvfb->stop();
});
} and then comment out the contents of the Edit [2017-06-05]: as noted below the code stopped working after a symfony update. Remove the two |
@SebastianS90 very handy, thanks! I'll give this a try. I'm unable to run dusk tests even after starting Xvfb, so I'm still trying to get that to work. For now, I switched to phantomjs and it's working, but that was more for a POC. I'll still be trying to use chrome through the methods mentioned above until I can put together a good configuration. |
@ockle solution worked for me. I'm using Homestead on a windows machine. |
Lots of solutions floating around but this here is the official solution that will be included in the next vagrant homestead box. I've tried it and it works good https://github.com/laravel/homestead/pull/528/files#diff-6c17dd8d21b8b745850a87b9d0de77c7 basically run
and then update your aliases with the latest ones which includes this new function
You can also alternatively use this release canditate homestead box which has the fix in it |
Solución propuesta por @ockle en: laravel/dusk#71
@SebastianS90 it seems that your code doesn't works with the latest symfony process :( |
On Ubuntu Linux 16.04, I got this to work: Install Chromium & dependencies for headless testing Create a custom public function handle()
{
$xvfb = (new ProcessBuilder())
->setTimeout(null)
->setPrefix('/usr/bin/Xvfb')
->setArguments(['-ac', ':0', '-screen', '0', '1280x1024x16'])
->getProcess();
$xvfb->start();
try {
parent::handle();
} finally {
$xvfb->stop();
}
return;
} |
@alejandrorosas Yes, there has been some change to symfony process. |
@vesper8 Thanks for your comment about running Is this expected behaviour, or am I doing something wrong? Thanks in advance. |
@vesper8 Sorry, ignore that last message - figured it out - just needed to re-provision Homestead again for changes to the |
There are 2 problems with this (I personally test it in Docker):
The commands I've run to get to error in step 2 were:
The text was updated successfully, but these errors were encountered: