简体   繁体   English

Laravel Dusk-无法连接到本地主机端口9515:连接被拒绝

[英]Laravel Dusk - Failed to connect to localhost port 9515: Connection refused

I want to create a test which I will use from Controller so I write: 我想创建一个要在Controller中使用的测试,所以我写:

<?php

namespace App\Http\Controllers\Modules;
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Laravel\Dusk\ElementResolver;
use Exception;

use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\Browser;
use Laravel\Dusk\Chrome\ChromeProcess;

class TestController extends Controller {



  public function test() {

    $process = (new ChromeProcess)->toProcess();
    if ($process->isStarted()) {
      $process->stop();
    }
    $process->start();

    $options      = (new ChromeOptions)->addArguments(['--disable-gpu', '--headless', '--no-sandbox']);
    $capabilities = DesiredCapabilities::chrome()
      ->setCapability(ChromeOptions::CAPABILITY, $options);

          $driver = retry(1, function () use ($capabilities) {
      return RemoteWebDriver::create('http://localhost:9515', $capabilities, 60000, 60000);
    }, 50);

    $browser = new Browser($driver, new ElementResolver($driver, ''));
    $browser->resize(1920, 1080);
    $browser->visit('https://example.com/login')->click('#.btn > form > div.auth-form-body.mt-3 > input.btn.btn-primary.btn-block');
    $browser->driver->takeScreenshot(base_path('tests/Browser/screenshots/logged.png'));

  }


}

When I run this script using localhost:8000/test I got this message: 当我使用localhost:8000 / test运行此脚本时,收到以下消息:

Facebook \\ WebDriver \\ Exception \\ WebDriverCurlException Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--disable-gpu","--headless","--no-sandbox"]}}} Failed to connect to localhost port 9515: Connection refused Facebook \\ WebDriver \\ Exception \\ WebDriverCurlException使用参数将HTTP POST抛出到/ session的卷发错误:{“ desiredCapabilities”:{“ browserName”:“ chrome”,“ platform”:“ ANY”,“ chromeOptions”:{“ binary”: “”,“ args”:[“-disable-gpu”,“-headless”,“-no-sandbox”]}}}无法连接到本地主机端口9515:连接被拒绝

在此处输入图片说明

How I can solve this problem? 我该如何解决这个问题?

Current I use WAMP server on Win10 for local testing but then I will move the code on Linux Ubuntu 18. 当前,我在Win10上使用WAMP服务器进行本地测试,但是随后我将在Linux Ubuntu 18上移动代码。

I can't fully explain it, but this works for me on Windows: 我无法完全解释它,但这在Windows上对我有用:

$process = (new ChromeProcess)->toProcess();
if ($process->isStarted()) {
  $process->stop();
}

$process->start(null, [
    'SystemRoot' => 'C:\\WINDOWS',
    'TEMP' => 'C:\Users\<User>\AppData\Local\Temp',
]);

[...]

Replace <User> with the name of your user directory. <User>替换为用户目录的名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel Dusk 错误:无法连接到 localhost 端口 9515:连接被拒绝 - Laravel Dusk error: Failed to connect to localhost port 9515: Connection refused 无法连接到本地主机端口 9515:连接被拒绝 - Failed to connect to localhost port 9515: Connection refused 连接被拒绝:无法连接到 127.0.0.1 端口 4444:连接被拒绝 laravel 黄昏与 selenium 和 laradock - Connection Refused : Failed to connect to 127.0.0.1 port 4444: Connection refused laravel dusk with selenium and laradock curl(7):无法连接到本地主机端口8000:连接被拒绝 - curl (7): Failed to connect to localhost port 8000: Connection refused cURL错误7:无法连接到本地主机端口4444:连接被拒绝 - cURL error 7: Failed to connect to localhost port 4444: Connection refused curl: (7) 无法连接到本地主机端口 3000:连接被拒绝 - curl: (7) Failed to connect to localhost port 3000: Connection refused java.net.ConnectException:无法连接到 localhost/127.0.0.1(端口 80):连接失败:ECONNREFUSED(连接被拒绝) - java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused) 无法连接到:localhost:27017:连接被拒绝 - Failed to connect to: localhost:27017: Connection refused 无法连接到数据库:无法连接到:localhost:27017:连接被拒绝 - Unable to connect to Database: Failed to connect to: localhost:27017: Connection refused cURL 错误 [0]:无法连接到 127.0.0.1 端口 8545:连接被拒绝 - cURL error [0]: Failed to connect to 127.0.0.1 port 8545: Connection refused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM