Comments (13)
@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:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg –i google-chrome-stable_current_amd64.deb
apt-get install -y xvfb
from dusk.
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
sudo apt-get update
sudo apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4
sudo apt-get -y install chromium-browser
sudo apt-get -y install xvfb gtk2-engines-pixbuf
sudo apt-get -y install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable
sudo apt-get -y install imagemagick x11-apps
and then update your aliases with the latest ones which includes this new function
function dusk() {
pids=$(pidof /usr/bin/Xvfb)
if [ ! -n "$pids" ]; then
Xvfb :0 -screen 0 1280x960x24 &
fi
php artisan dusk "$@"
}
You can also alternatively use this release canditate homestead box which has the fix in it
https://atlas.hashicorp.com/Svpernova09/boxes/nothomestead
from dusk.
@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:
chmod 755 vendor/laravel/dusk/bin
from dusk.
@alejandrorosas Yes, there has been some change to symfony process.
Remove the two lines ->add('exec')
and it should work again.
from dusk.
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?
from dusk.
Hi everyone, I'm having the same issue in a Docker container based off of php:7-apache
which is debian jessie
.
I tried installing chrome/xvfb and modifying the SupportsChrome
trait in vendor/laravel/dusk/src
without success.
I'm still stuck on Operation timed out after 30001 milliseconds with 0 bytes received
.
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!
from dusk.
@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 script -q -e -c 'php artisan dusk'
And for the xvfb part I just use my own DuskCommand
class which overrrides the original one as follows:
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 prepare
function in DuskTestCase
Edit [2017-06-05]: as noted below the code stopped working after a symfony update. Remove the two ->add('exec')
lines and it should work again.
from dusk.
@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.
from dusk.
@ockle solution worked for me. I'm using Homestead on a windows machine.
This fix should be implemented asap in the package.
from dusk.
@SebastianS90 it seems that your code doesn't works with the latest symfony process :(
from dusk.
On Ubuntu Linux 16.04, I got this to work:
Install Chromium & dependencies for headless testing
sudo apt-get -y install chromium-browser xvfb gtk2-engines-pixbuf xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable imagemagick x11-apps
Create a customDuskCommand
Which extends the original, with this handle
method:
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;
}
from dusk.
@vesper8 Thanks for your comment about running dusk
directly within Homestead. This gets Dusk to work headlessly for me, but, the error screenshots being saved are 800x600px in size, despite having set the Xvfb arguments to 1280x960x24
.
Is this expected behaviour, or am I doing something wrong? Thanks in advance.
from dusk.
@vesper8 Sorry, ignore that last message - figured it out - just needed to re-provision Homestead again for changes to the aliases
file to take effect. Thanks!
from dusk.
Related Issues (20)
- Enable performance logging for Chrome Driver HOT 1
- Allow a test class to be retried HOT 1
- A way to have different environment variables HOT 2
- Dusk v7.8.0 breaks Pest support
- Downloading ChromeDriver 115+ fails HOT 7
- Dusk 7.9.0 \ chromedriver.exe path not found HOT 11
- [7.9.1] unknown error: cannot find Chrome binary HOT 5
- `--stop-on-failure` option no longer seems to work HOT 1
- Driver won't download with Telescope enabled HOT 8
- unknown error: cannot find Chrome binary HOT 1
- Error This version of ChromeDriver only supports Chrome version 114 Current browser version is 118.0.5975.0 HOT 1
- Assertion failure can lead to timeout if using multiple browsers HOT 5
- Test class with no tests gives non-zero stderr status, but no warning to stdout and shows all tests pass HOT 5
- Unexpected behaviour when working with multiple checkboxes HOT 1
- waitForTextIn() broken in dusk 7.11.2 HOT 2
- Unknown option "--ansi" and "--no-ansi"
- Laravel Dusk doesn't trigger on @input when attached to <select> only on @change when using Vue HOT 2
- When running `php artisan dusk` the tests do not complete. They just hang. - MacOS Sonoma 14.2.1, Chip: M3 Pro HOT 9
- Throwing an exception in a dusk test inside the browser callback results in timeouts HOT 2
- vueAttribute does not work with Vue 3 and vite build. only with vite dev. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dusk.