简体   繁体   English

连接被拒绝:无法连接到 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

I am using laradock https://github.com/laradock/laradock for development environment setup.我正在使用 laradock https://github.com/laradock/laradock进行开发环境设置。 Everything looks good untill I have tried to run dusk test in the environment.在我尝试在环境中运行黄昏测试之前,一切看起来都很好。

This is the output of command php artisan dusk这是命令php artisan dusk的 output

root@e686e0cbda43:/var/www/stability_v54# php artisan dusk --filter test_WhenEmptyFormIsSubmitted_ShowErrorMessages 
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 28.59 seconds, Memory: 34.00MB

There was 1 error:

1) Tests\Browser\NurseRegisterTest::test_WhenEmptyFormIsSubmitted_ShowErrorMessages
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"w3c":false,"binary":"","args":["--disable-gpu","--no-sandbox","--ignore-ssl-errors","--whitelisted-ips=\"\"","--headless"]}}}

Failed to connect to 127.0.0.1 port 4444: Connection refused

/var/www/stability_v54/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:297
/var/www/stability_v54/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:144
/var/www/stability_v54/tests/DuskTestCase.php:64
/var/www/stability_v54/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:185
/var/www/stability_v54/vendor/laravel/framework/src/Illuminate/Support/helpers.php:765
/var/www/stability_v54/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:186
/var/www/stability_v54/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:92
/var/www/stability_v54/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:64
/var/www/stability_v54/tests/Browser/NurseRegisterTest.php:98

here is DuskTestCase ,这是DuskTestCase

<?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;

    protected function setUp()
    {
        //Set wait env variables
        $this->quickWait  = env('QUICK_WAIT', false);
        $this->shortWait  = env('SHORT_WAIT', false);
        $this->mediumWait = env('MEDIUM_WAIT', false);
        $this->longWait   = env('LONG_WAIT', false);

        parent::setUp();

        foreach (static::$browsers as $browser) {
            $browser->driver->manage()->deleteAllCookies();
        }
    }

    /**
     * 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()
    {
        $arguments = [
            '--disable-gpu',
            '--no-sandbox',
            '--ignore-ssl-errors',
            '--whitelisted-ips=""',
        ];

        $headlessMode = env('DUSK_HEADLESS_MODE', false);

        if($headlessMode) {
            array_push($arguments, '--headless');
        }

        $options = (new ChromeOptions)->addArguments($arguments);

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

I have following version of chrome driver and selenium.我有以下版本的 chrome 驱动程序和 selenium。

Chrome version 88.0.4324.96 Selenium Standalone v.3.141.59 Chrome 版本 88.0.4324.96 Selenium 独立 v.3.141.59

Somewhere I found I have to update these two into latest version, but these are already latest ones in my setup.在某处我发现我必须将这两个更新为最新版本,但这些已经是我设置中的最新版本。

This question may sound duplicate but I have already tried the available ones in this community.这个问题听起来可能是重复的,但我已经尝试过这个社区中可用的问题。

If somebody know the reason behind this please share, it will be extremly helpful.如果有人知道这背后的原因,请分享,这将非常有帮助。

The Curl error thrown for POST... means your dusk test case was unable to connect with the selenium endpoint entirely. Curl error thrown for POST...意味着您的黄昏测试用例无法完全连接到 selenium 端点。

I see that you used 127.0.0.1 in your driver setup我看到您在驱动程序设置中使用了127.0.0.1

 protected function driver() { return RemoteWebDriver::create('http://127.0.0.1:4444', ...

but, assuming you're running php artisan dusk inside your laradock workspace container, that container can't see the seleninum host at http://127.0.0.1 .但是,假设您在 laradock 工作空间容器运行php artisan dusk Huang ,该容器无法看到位于http://127.0.0.1的 seleninum 主机。 However, because of the frontend network set up between containers by docker compose, that container can see it at http://selenium但是,由于 docker 组合在容器之间设置的frontend网络,该容器可以在 http://selenium 看到它

Also, I think you also need to specify path /wd/hub under selenium另外,我认为您还需要在 selenium 下指定路径 /wd/hub

So try this:所以试试这个:

  1. return RemoteWebDriver::create('http://selenium:4444/wd/hub', ...
  2. Run dusk inside your laradock workspace container, eg在 laradock 工作区容器中运行黄昏,例如
    docker-compose exec -u laradock workspace php artisan dusk

暂无
暂无

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

相关问题 Laravel Dusk-无法连接到本地主机端口9515:连接被拒绝 - Laravel Dusk - Failed to connect to localhost port 9515: Connection refused Laravel Dusk 错误:无法连接到 localhost 端口 9515:连接被拒绝 - Laravel Dusk error: Failed to connect to localhost port 9515: Connection refused cURL错误7:无法连接到本地主机端口4444:连接被拒绝 - cURL error 7: Failed to connect to localhost port 4444: Connection refused 我如何解决在 laradock selenium 中连接失败和连接被拒绝的问题 - how i can fix Failed to connect and Connection refused in laradock selenium cURL 错误 [0]:无法连接到 127.0.0.1 端口 8545:连接被拒绝 - cURL error [0]: Failed to connect to 127.0.0.1 port 8545: Connection refused 如何使用laradock与postgres配置laravel? 无法连接到服务器:端口5432上的连接被拒绝 - how to configure laravel with postgres using laradock? could not connect to server: Connection refused on port 5432 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) 无法连接到本地主机端口 9515:连接被拒绝 - Failed to connect to localhost port 9515: Connection refused local.ERROR:cURL 错误 7:无法连接到 127.0.0.1 端口 7700:连接被拒绝 - local.ERROR: cURL error 7: Failed to connect to 127.0.0.1 port 7700: Connection refused 连接被拒绝 [tcp://127.0.0.1:6379] Laravel Predis - Connection refused [tcp://127.0.0.1:6379] Laravel Predis
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM