dusk: Problem running dusk on Homestead
Hello,
So I just installed a new Laravel 5.4 project and thought I’d give Dusk a try…
Followed the installation steps in the documentation:
- Ran
composer require laravel/dusk - Updated
AppServiceProvider.php - Ran
php artisan dusk:install
But when I run php artisan dusk I get the following output:
dir=$(d=${0%[/\\]*}; cd "$d"; cd "../phpunit/phpunit" && pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m "$dir");
fi
fi
dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/phpunit" "$@"
It seems to be outputting the script instead of executing it.
I’m running latest Homestead on Windows 10 with PHP 7.1.0-2+deb.sury.org~xenial+1 (cli) ( NTS )
PS. PHPUnit works as expected.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 41 (12 by maintainers)
Finally got it working in Vagrant on Ubuntu 14.04 (not a Homestead image though). My host OS is Windows 10.
First of all,
google-chromeis requried to be installed in guest OS:Next thing is
xvfb:Try to start
./vendor/laravel/dusk/bin/chromedriver-linux --port=8888. If you have some errors about loading libraries (libnss3.so,libgconf-2.so.4), try this:When you see
this means ChromeDriver can be started (so
SupportsChrometrait should be able to start it too). You can stop this process for now (Ctrl+C).Run
in a separate terminal window.
Also you may want to add your dev domain in guest’s
/etc/hostsfile:127.0.0.1 domain.dev.And finally run
I didn’t try more complex tests for now, but assume they should work. The only thing I’ve noticed not working is a screenshot feature. I have blank white screen instead of actual browser window.
Edit: screenshots feature is working, just don’t load Google Fonts.
just to clarify I had the same problem - I did:
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
chmod a+x ./vendor/laravel/dusk/bin/chromedriver-linux
and it seemed to have solved the problem
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 candidate homestead box which has the fix in it https://atlas.hashicorp.com/Svpernova09/boxes/nothomestead
The following, (taken from here) worked for me:
nope, just comment out the
--headlessline on thedriver()method inDuskTestCaseOK! My answer here : https://developers.google.com/web/updates/2017/04/headless-chrome :
is this fixing it for other people? I am still having issues on the current v1.0.5
@webcrazy same issue here (Laravel 5.5, Win10, Homestead). What makes me said, is that, it was working fine, at least for last couple of months. For me, one issue is that, screenshots are blank/white. The other one, I am facing, is getting failed tests, when I use
assertPathIs()after redirect. It happens only, if I run chromedriver in headless mode. With windowed mode, all tests pass green. What is intriguing, that my tests pass green in my gitlab CI.So this issue is even more confusing… BTW I’ve tried chromedriver 2.33 and 2.35, same result.
@browner12 Thanks. If i disabled --headless, it works as expected but if I turn on, I got error and error screenshots become blank. not sure why. looks like I will have to stick with --headless for the time being.
not really sure. might be legacy hack from before Chrome had a true “headless” mode.
seeing as Chrome “headless” was released in June of this year, this seems most likely.
Ok but what is Xvfb for then ?
Xvfb -ac :0 -screen 0 1280x1024x16 &: This is running on the headless homestead VM ? How does the graphical chrome on host gets fired then ?@tzurbaev thanks for your comment. Saved my butt.
@murribu Thank! This really help. I can run duck in Homestead.
I am still having issues on the current v1.0.5, too.
@browner12
No, I get a timeout:
@SaeedPrez On my end https://github.com/laravel/dusk/pull/70 fixed this (but haven’t run full Dusk test yet because of further connection problems that I need to solve in free time that were mentioned also in this thread)
I’m having issues running on Homestead as well, but I’m running my Vagrant box on Linux Mint. I have updated Homestead to latest, and tried using a new test site. Also, tried the various methods listed above which didn’t work.
If I follow the Dusk setup exactly, I get the following:
EDIT
I have gotten a little farther by marking the /vendor/laravel/dusk/bin/chromedriver-linux executable:
chmod a+x ./vendor/laravel/dusk/bin/chromedriver-linuxAfter making this edit, I now get a timeout error:
I tried another solution from @abalozz (#10).
apt-get install xvfbstatic::$chromeProcess = new Process('xvfb-run ./chromedriver-linux', realpath(__DIR__.'/../bin'), null, null, null);Unfortunately, this solution seems to be buggy since the tests are sometimes very slow to run.