在无头(无GUI)计算机上运行Laravel Dusk [英] Running Laravel Dusk on Headless (no GUI) machine
问题描述
随着Laravel 5.4的最新发布,我想尝试一下.就像Reddit上的 Ozymandias-X 一样,我也感到沮丧它.
With the recent announcement of Laravel 5.4, I thought I'd give it a try. Like Ozymandias-X on Reddit, I also have been frustrated by it.
- Windows 10作为主机;
- 将CentOS 7作为Guest(没有GUI安装,没有Vagrant)
- 与Virtual Box共享的文件夹.
如果我仅打开机器并运行php artisan dusk
,则会得到以下信息:
If I just turn on my machine and run php artisan dusk
, I get the following:
[08:14 AM]-[root@php7]-[/var/www/html/admin]-[git master]
# php artisan dusk
PHPUnit 5.7.11 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 25.91 seconds, Memory: 10.00MB
There was 1 error:
1) Tests\Browser\LoginTest::it_should_see_email_error_message
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"\/usr\/lib64\/chromium-browser\/chromedriver","args":["no-first-run"]}}}
Operation timed out after 5001 milliseconds with 0 out of -1 bytes received
/var/www/html/admin/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:287
/var/www/html/admin/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:121
/var/www/html/admin/tests/DuskTestCase.php:42
/var/www/html/admin/vendor/laravel/dusk/src/TestCase.php:180
/var/www/html/admin/vendor/laravel/framework/src/Illuminate/Support/helpers.php:639
/var/www/html/admin/vendor/laravel/dusk/src/TestCase.php:181
/var/www/html/admin/vendor/laravel/dusk/src/TestCase.php:111
/var/www/html/admin/vendor/laravel/dusk/src/TestCase.php:85
/var/www/html/admin/tests/Browser/LoginTest.php:24
ERRORS!
Tests: 1, Assertions: 1, Errors: 1.
我试图关注迈克·史密斯的文章 ,但是手动执行./vendor/laravel/dusk/bin/chromedriver-linux
并从DuskTestCase注释掉static::startChromeDriver();
根本没有帮助.我还尝试安装Xvfb并手动在端口:0上运行它,并且发生了同样的事情.
最后,我尝试从/usr/lib64/chromium-browser/chromedriver
(2.25)手动运行驱动程序,根本没有任何更改.
I tried to follow Mike Smith's article, but executing ./vendor/laravel/dusk/bin/chromedriver-linux
manually and commenting out static::startChromeDriver();
from DuskTestCase didn't help at all. I also tried installing Xvfb and running it on port :0 manually and same thing happens.
Lastly, I tried running the driver manually from /usr/lib64/chromium-browser/chromedriver
(2.25) and no change at all.
我试图避免直接从Windows运行此程序,因为我打算使用无头/无GUI linux进行CI进程,并且必须设置与我现在尝试的相同的东西.
I'm trying to avoid running this from Windows directly because I intend to have a CI process with a headless/no-gui linux and I'll have to set up the same thing I'm trying right now.
推荐答案
解决方案是使用no-sandbox
运行chrome或根本不以root身份运行.我创建了一个名为 dusk 的用户,在该用户下Dusk可以正常工作.
The solution is to either run chrome with no-sandbox
or NOT run it as root at all. I created a user called dusk and under that Dusk will work with no problems.
login as: dusk
dusk@192.168.56.70's password:
Last login: Mon Mar 6 13:07:30 2017 from 192.168.56.1
[dusk@php7 ~]$ Xvfb -ac :0 -screen 0 1280x1024x16 &
[1] 2177
[dusk@php7 ~]$ cd /var/www/solucoesideais/laravel-dusk/
[dusk@php7 laravel-dusk]$ php artisan serve --host=127.0.0.1 --port=8000 --env=dusk.environment &
[2] 2186
[dusk@php7 laravel-dusk]$ Laravel development server started: <http://127.0.0.1:8000>
[dusk@php7 laravel-dusk]$ php artisan dusk
PHPUnit 5.7.15 by Sebastian Bergmann and contributors.
[Mon Mar 6 13:23:28 2017] 127.0.0.1:59146 [200]: /favicon.ico
. 1 / 1 (100%)
Time: 3.7 seconds, Memory: 10.00MB
OK (1 test, 1 assertion)
[dusk@php7 laravel-dusk]$
这篇关于在无头(无GUI)计算机上运行Laravel Dusk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!