Laravel Dusk:FacebookWebDriverExceptionUnknownErrorException:未知错误:NET::ERR_CONNECTION_REJECTED

运行php artisan dusk获得错误:

FacebookWebDriverExceptionUnknownErrorException: unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: headless chrome=85.0.4183.83)

版本:

  • 操作系统:Windows 10 v1903内部版本18362.1016
  • 铬:85.0.4183.83
  • Laravel:v6.18.37
  • 黄昏:v5.11.0
  • Phpunit:v8.5.8

已尝试:

  • 禁用防火墙
  • 将测试网站设置为使用localhost(WAS myapp.local)
  • 可以使用Chrome浏览器访问所有页面
  • 检查供应商/laravel/dusk/bin/chromedriver-win.exe是否可执行(-rwxr-xr-x)
  • php工匠路线:清除
  • php artisan缓存:清除
  • php artisan配置:清除
  • 作曲器转储-自动加载
  • 谷歌";FacebookWebDriverExceptionUnknownErrorException:未知错误:NET::ERR_CONNECTION_REJECTED&QOOT;

服务器localhost:9515在执行测试时似乎正在运行,因为我在尝试它时在Chrome中得到以下响应:

{
    value: {
        error: "unknown command",
        message: "unknown command: unknown command: ",
        stacktrace: "Backtrace: Ordinal0 [0x0037D383+3134339] Ordinal0 [0x0026A171+2007409] Ordinal0 [0x0010AEE8+569064] Ordinal0 [0x000AD12C+184620] Ordinal0 [0x000ACF0A+184074] Ordinal0 [0x00081FD7+8151] Ordinal0 [0x00082496+9366] Ordinal0 [0x00082B40+11072] Ordinal0 [0x00280CD9+2100441] GetHandleVerifier [0x004EB75A+1396954] GetHandleVerifier [0x004EB3D9+1396057] GetHandleVerifier [0x004F7126+1444518] GetHandleVerifier [0x004EBCE8+1398376] Ordinal0 [0x00277F51+2064209] Ordinal0 [0x00081D35+7477] Ordinal0 [0x00081991+6545] GetHandleVerifier [0x006BF31C+3312796] BaseThreadInitThunk [0x76986359+25] RtlGetAppContainerNamedObjectPath [0x771D7C24+228] RtlGetAppContainerNamedObjectPath [0x771D7BF4+180] (No symbol) [0x00000000] ",
    }
}

DuskTestCase驱动程序:

/**
 * Create the RemoteWebDriver instance.
 *
 * @return FacebookWebDriverRemoteRemoteWebDriver
 */
protected function driver()
{
    $options = (new ChromeOptions)->addArguments([
        '--disable-gpu',
        '--headless',
        '--window-size=1920,1080',
    ]);

    return RemoteWebDriver::create(
        'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
            ChromeOptions::CAPABILITY, $options
        )
    );
}

有没有人有其他可以尝试的线索?或者其他人知道解决方案吗?


解决方案

我也遇到过同样的问题,对我来说起作用的是将.env文件中的APP_URL参数设置为:

APP_URL=http://127.0.0.1:8000

因为这是我的php artisan serve也将为网站提供服务的同一端口,即

Laravel development server started: http://127.0.0.1:8000

相关文章