Tre*_*vor 7 php automated-tests google-chrome laravel laravel-6
运行 php artisan dusk 得到错误:
Facebook\WebDriver\Exception\UnknownErrorException: unknown error: net::ERR_CONNECTION_REFUSED
(Session info: headless chrome=85.0.4183.83)
Run Code Online (Sandbox Code Playgroud)
版本:
尝试:
服务器 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] ",
}
}
Run Code Online (Sandbox Code Playgroud)
DuskTestCase 驱动程序:
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
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
)
);
}
Run Code Online (Sandbox Code Playgroud)
有没有人有任何线索可以尝试什么?或者其他人知道解决方案吗?
Val*_*loş 14
我将其发布给其他可能面临与我相同问题的人。
事实证明,Laravel Duskphp artisan serve在运行之前就希望我们先运行php artisan dusk!该ERR_CONNECTION_REFUSED错误是指无法连接到http://localhost:8000应用程序本身的 URL,因为它没有运行。
这确实有道理,但我根本不知道,而且文档对此也不清楚(我不得不推断它)。然而,ChromeDriver 是在执行时由 Dusk 自动启动的。
我遇到了同样的问题,对我来说有效的是将APP_URL.env 文件中的参数设置为:
APP_URL=http://127.0.0.1:8000
Run Code Online (Sandbox Code Playgroud)
因为那是我php artisan serve也可以为网站提供服务的同一个端口,即
Laravel development server started: http://127.0.0.1:8000
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3639 次 |
| 最近记录: |