我正在尝试使用Laravel Dusk,但是,我无法让它正常运行。基于我在控制台中运行它时的反馈以及在黄昏被释放之前some google searches和the fact I'd experienced the same issues with a similar package,我猜测问题归结为在我的工作场所背后的代理。关于代理问题我当然是错的,但这是我现在唯一要做的事情。如果我诚实,我甚至不明白为什么它需要知道我在本地运行本地测试的代理设置?
我做了以下安装黄昏:
composer require laravel/dusk
APP_URL=http://ticket.dev
AppServiceProvider
register()
方法中添加了以下内容:应用/提供者/ AppServiceProviders.php
use Laravel\Dusk\DuskServiceProvider;
//...
public function register()
{
if ($this->app->environment('local', 'testing')) {
$this->app->register(DuskServiceProvider::class);
}
}
当我运行php artisan dusk
时,我在控制台中获得以下内容:
1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverException: JSON decoding of remote response failed.
Error code: 4
The response: '<!DOCTYPE html>
<html>
<head>
<title>Laragon</title>
// the rest of the output is what http://localhost produces
所以它似乎正在点击http://localhost而不是我的APP_URL?
我找到了这个github wiki page,在浏览了与Dusk相关的供应商文件夹后,我尝试在文件driver()
的{{1}}函数中设置驱动程序时设置代理。 / p>
我尝试过以下操作,但是我得到了前面提到的相同的控制台输出:
tests/DuskTestCase.php
和......
protected function driver()
{
// same as DesiredCapabilities::chrome() except with proxy info
$capabilities = new DesiredCapabilities([
WebDriverCapabilityType::BROWSER_NAME => WebDriverBrowserType::CHROME,
WebDriverCapabilityType::PLATFORM => WebDriverPlatform::ANY,
WebDriverCapabilityType::PROXY => [
'proxyType' => 'manual',
'httpProxy' => 'http://proxy:8080',
'sslProxy' => 'http://proxy:8080',
],
]);
return RemoteWebDriver::create(
'http://localhost:9515',
$capabilities,
);
// original code after installation
// return RemoteWebDriver::create('http://localhost:9515', DesiredCapabilities::chrome());
}
任何帮助您完成这项工作将不胜感激,谢谢!