Homestead: Add ChromeDriver

Created on 11 Mar 2017  Â·  17Comments  Â·  Source: laravel/homestead

Can we natively add the ChromeDriver in Homestead so we can run Laravel Dusk tests?

https://laravel.com/docs/5.4/dusk
https://sites.google.com/a/chromium.org/chromedriver/home

Most helpful comment

Made this command real quick:

#!/bin/sh

pids=$(pidof /usr/bin/Xvfb)
if [ ! -n "$pids" ]; then
    Xvfb :0 -screen 0 1280x960x24 &
fi

php artisan dusk

./dusk.sh

All 17 comments

I managed to get it to work with these install commands:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update && sudo apt-get install -y google-chrome-stable
sudo apt-get install -y xvfb

More info here: https://github.com/laravel/dusk/issues/50#issuecomment-275155974

This is really important: (from the comment above) you need to run Xvfb :0 -screen 0 1280x960x24 & before attempting to run Laravel dusk or it will timeout. Perhaps it could be nice if we could run it when the machine starts up so the process is always running?

When you're on your local machine you don't need to do this because Chrome probably is already running. But on Homestead you'll need to explicitly tell the chrome driver to start.

I'm all for it, just haven't had time to get around to doing it. I'd like to add it to settler and then have an alias in Homestead to run the Xvfb :0 -screen 0 1280x960x24 &, If you're not using Dusk I wouldn't want that process running, so I think manually starting it is a better way to go.

Yeah, agree. Just wish it wasn't so cumbersome. Currently trying to find a way to combine it in one command but no luck so far.

Made this command real quick:

#!/bin/sh

pids=$(pidof /usr/bin/Xvfb)
if [ ! -n "$pids" ]; then
    Xvfb :0 -screen 0 1280x960x24 &
fi

php artisan dusk

./dusk.sh

@driesvints I'm going to get this added to Settler soonâ„¢ with a next box version due mid April. (trying not to push those out more than once a month if I can help it)

@svpernova09 ok great! Definitely not urgent.

@driesvints I ran into some weird things when I ran dusk in (and out of) vagrant it kept telling me to install dependencies and linking me to gegtcomposer.org Didn't get much further than that. Outside of vagrant following the normal guide everything worked. Any ideas?

Not sure. Didn't have that. What is the exact CLI output?

I actually managed to get Dusk fully running in the end but reverted everything and just used the browser-kit package. I didn't get some of the assertions to work in Dusk and I had to port all of my tests to the new Dusk way of doing things. In the end it wasn't worth the hassle so I decided to go for the browser-kit package which tests run much faster anyway.

I'll have to reconfigure everything, I also reverted a ton of it.

My biggest let down (just being spoiled by browser-kit testing) was Dusk had no way of rolling back database changes. I have a project where I have to import a data set then run migrations, so I end up just keeping a sql file of the data in a known good state and then import it every time I run tests (and run them against a test DB)

Resolved via #532 #528

Thanks to @syntacticNaCl for the PR that ultimately ended up getting merged into Settler

You can test this by adding:

box: svpernova09/nothomestead

To your Homestead.yaml file. Then destroy & up vagrant. Please report any issues related to dusk.

Thanks @svpernova09. I pulled it down and everything worked great.

Hmm, tried svpernova09 homestead box but still same problem

Failed to connect to localhost port 9515: Connection refused

I'm using Ubuntu 16.04, don't know is it something to do with app conf or my host machine.
Any help?

@KevinLeht can you vagrant ssh into the homestead box and run ps aux | grep Xvfb and see if Xvfb is running? You should see this as an output: Xvfb :0 -screen 0 1280x960x24

@syntacticNaCl
ps aux | grep Xvfb

gives me output:

vagrant   2634  0.0  1.7 178568 35356 ?        S    06:21   0:00 Xvfb :0 -screen 0 1280x960x24
vagrant   5694  0.0  0.0  14232   936 pts/2    S+   09:09   0:00 grep --color=auto Xvfb

@syntacticNaCl Same here, I'm getting the same output as Kevin:

$ ps aux | grep Xvfb
vagrant   2588  0.0  1.7 178568 35428 pts/0    S    02:53   0:00 Xvfb :0 -screen 0 1280x960x24
vagrant   2681  0.0  0.0  14232  1012 pts/0    S+   02:55   0:00 grep --color=auto Xvfb

@KevinLeht apologies for not getting back to you, this fell off my radar. @ipalaus @KevinLeht Have you tried switching to the newest homestead box since it now has this functionality added? If you have and it is still not working, please post the full output of the error you are receiving.
One fix other people have found success with is try setting the permissions on chromedriver-linux chmod a+x ./vendor/laravel/dusk/bin/chromedriver-linux from within your project root and then kill Xvfb and run dusk again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yazeed picture yazeed  Â·  3Comments

teleclimber picture teleclimber  Â·  3Comments

cschoeni picture cschoeni  Â·  4Comments

Quix0r picture Quix0r  Â·  4Comments

daryn-k picture daryn-k  Â·  5Comments