【发布时间】:2020-12-02 09:06:39
【问题描述】:
我想用 Dusk 测试我的 laravel 项目。
但是当我运行php artisan dusk 时,我有这个:
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"binary":"","args":["--disable-gpu","--headle
ss","--window-size=1920,1080"]},"acceptInsecureCerts":true}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--disable-gpu","--headless","--window-size=1920,1080"]},"acceptInsecu
reCerts":true}}
Could not resolve host: selenium
我已将黄昏配置为使用我的硒容器。
我的配置:
<?php
namespace Tests;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\TestCase as BaseTestCase;
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',
]);
return RemoteWebDriver::create(
'http://selenium:4444/wd/hub', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
->setCapability('acceptInsecureCerts', true), 60*1000, 60*1000
);
}
}
Selenium 在 docker 容器中。 Selenium 的配置:
selenium:
image: selenium/standalone-chrome:3.11.0-antimony
networks:
- project
我知道这是因为我的项目没有到达以连接到我的容器,但我不知道如何解决这个问题。
如果有人可以帮助我,那就太好了... 非常感谢!
【问题讨论】:
标签: selenium selenium-webdriver laravel-dusk