gpt4 book ai didi

php - 浏览器 “DevToolsActivePort file doesn' t 存在的 Dusk 测试”

转载 作者:行者123 更新时间:2023-12-05 03:01:01 24 4
gpt4 key购买 nike

我正在为浏览器运行 Laravel Dusk 的示例测试,但是当我执行 php artisan dusk 时出现错误

使用:* Ubuntu 18* 拉维尔 5.8*黄昏5.1* Chrome 驱动程序 74* Apache 2

这是我的 DuskTestCase.php:

    <?php

namespace Tests;

use Laravel\Dusk\TestCase as BaseTestCase;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;

abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;

/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
static::startChromeDriver();
}

/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--window-size=1920,1080',
'--disable-dev-shm-usage',
'--no-sandbox'
]);

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

这是错误:

    1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\UnknownServerException: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /snap/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Linux 4.18.0-20-generic x86_64)

最佳答案

在我的例子中,我发现我需要将 --no-sandbox 添加到 tests/DuskTestCase.php,因为我在 lxd 容器上以根目录运行.

我通过运行发现错误:vendor/laravel/dusk/bin/chromedriver-linux --log-level=ALL 并在另一个终端运行 php artisan dusk。它将显示日志,我能够从那里推断出问题。

关于php - 浏览器 “DevToolsActivePort file doesn' t 存在的 Dusk 测试”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56278372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com