Laravel6 启动dusk时遇到JSON decoding of remote response failed

今天第一次使用Laravel Dusk来写UI测试。

按照文档安装好dusk,使用php artisan dusk尝试跑测试后,报了以下错误:

Facebook\WebDriver\Exception\WebDriverException: JSON decoding of remote response failed.
Error code: 4
The response: ''

搜索了一圈,在这个链接找到一个解决方法。需要先用./vendor/laravel/dusk/bin/chromedriver-mac-intel --port=9515这个命令启动chrome,再跑php artisan dusk才可以。(我用的是Intel版的mac,其他版本有对应的chrome driver)

我觉得很奇怪,dusk命令居然还要我手动启动chrome的吗?

后来试了一下关闭启动了的chromedriver,并在dusk命令前添加了sudo:sudo php artisan dusk
果然代码可以跑通了。

但我看chromedriver-mac-intel文件是-rwxr-xr-x,不应该启动不了啊?

在网上搜索了一圈,说要用php artisan dusk:chrome-driver --proxy=0.0.0.0:8888命令先安装chrome driver,但文件是存在的。太奇怪了。安装了之后,再跑php artisan dusk,现在报的错就不一样了:

Facebook\WebDriver\Exception\UnknownErrorException: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location ./vendor/laravel/dusk/bin/chromedriver-mac-intel is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

在网上搜索了第二圈,说安装了之后要重启才行。俗话说重启大法好,那我就重启看看吧。

重启之后果然就好了……

标签:none

添加新评论