Laravel黄昏Chrome驱动程序超时 [英] Laravel dusk chrome driver timeout

查看:280
本文介绍了Laravel黄昏Chrome驱动程序超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮忙,我无法使Laravel处于黄昏状态,无法在mac high sierra上的当前Laravel 5.6项目中运行默认的示例测试.

Can anyone help, I am unable to get Laravel dusk to run the default sample test in my current Laravel 5.6 project on mac high sierra.

错误消息

时间:2.5分钟,内存:14.00MB

Time: 2.5 minutes, Memory: 14.00MB

有1个错误:

1)测试\浏览器\示例Test :: testBasicExample Facebook \ WebDriver \ Exception \ WebDriverCurlException:使用参数将HTTP POST抛出到/session抛出的卷发错误:{"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary" :"/Users/keith/Desktop/dusk/vendor/laravel/dusk/bin/chromedriver-mac","args":[-disable-gpu"]}}}

1) Tests\Browser\ExampleTest::testBasicExample Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"/Users/keith/Desktop/dusk/vendor/laravel/dusk/bin/chromedriver-mac","args":["--disable-gpu"]}}}

操作在30002毫秒后超时,收到0个字节

Operation timed out after 30002 milliseconds with 0 bytes received

/Users/keith/Desktop/dusk/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:286 /Users/keith/Desktop/dusk/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126 /Users/keith/Desktop/dusk/tests/DuskTestCase.php:40 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:189 /Users/keith/Desktop/dusk/vendor/laravel/framework/src/Illuminate/Support/helpers.php:770 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:190 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:92 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:64 /Users/keith/Desktop/dusk/tests/Browser/ExampleTest.php:21

/Users/keith/Desktop/dusk/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:286 /Users/keith/Desktop/dusk/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126 /Users/keith/Desktop/dusk/tests/DuskTestCase.php:40 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:189 /Users/keith/Desktop/dusk/vendor/laravel/framework/src/Illuminate/Support/helpers.php:770 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:190 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:92 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:64 /Users/keith/Desktop/dusk/tests/Browser/ExampleTest.php:21

我已经完成以下操作:

  • 将以下内容添加到app \ Providers \ AppServiceProvider.php

使用Laravel \ Dusk \ DuskServiceProvider;

use Laravel\Dusk\DuskServiceProvider;

...

public function register()

{

    if ($this->app->environment('local', 'testing')) {

        $this->app->register(DuskServiceProvider::class);
    }

}

  • 在终端中运行"php artisan dusk:install"
  • 将.env中的App_URL设置为 http://localhost:8000
  • 指定了DuskTestCase中chromedriver的位置
  • 在运行"php artisan黄昏"之前,先启动"php artisan服务"
    • ran 'php artisan dusk:install' in terminal
    • set App_URL in .env to http://localhost:8000
    • specified the location of chromedriver in DuskTestCase
    • start 'php artisan serve' before running 'php artisan dusk'
    • 存储库: https://github.com/KKOA/dusk

      推荐答案

      在实例化浏览器时尝试此操作..最重要的是$driver = retry(5, function () use ($capabilities) { return RemoteWebDriver::create('http://localhost:9515', $capabilities, 60000, 60000);

      try this while you instantiate your browser.. the most important is $driver = retry(5, function () use ($capabilities) { return RemoteWebDriver::create('http://localhost:9515', $capabilities, 60000, 60000);

      下面是我实例化浏览器的方式

      Below is how i instantiate my browser

      $options      = (new ChromeOptions)->addArguments(['--disable-gpu', '--headless', '--no-sandbox']);
      $capabilities = DesiredCapabilities::chrome()
        ->setCapability(ChromeOptions::CAPABILITY, $options)
        ->setPlatform('Linux');
      $driver       = retry(5, function () use ($capabilities) {
        return RemoteWebDriver::create('http://localhost:9515', $capabilities, 60000, 60000);
      }, 50);
      
      $browser = new Browser($this->driver, new ElementResolver($driver, ''));
      

      这篇关于Laravel黄昏Chrome驱动程序超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆