Laravel Dusk error: Failed to connect to localhost port 9515: Connection refused

后端 未结 6 957
粉色の甜心
粉色の甜心 2021-02-05 01:16

As the title says, I\'ve go a clean install of Laravel 5.4 and the latest Homestead (1.0.1). However, when I run a simple Dusk test case I get the following error:

6条回答
  •  礼貌的吻别
    2021-02-05 01:31

    On Ubuntu Linux 16.04, I got this to work:

    Install Chromium & dependencies for headless testing

    sudo apt-get -y install chromium-browser xvfb gtk2-engines-pixbuf xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable imagemagick x11-apps

    Create a customDuskCommand

    Which extends the original, with this handle method:

    public function handle()
    {
        $xvfb = (new ProcessBuilder())
            ->setTimeout(null)
            ->setPrefix('/usr/bin/Xvfb')
            ->setArguments(['-ac',  ':0', '-screen', '0', '1280x1024x16'])
            ->getProcess();
    
        $xvfb->start();
    
        try {
            parent::handle();
        } finally {
            $xvfb->stop();
        }
    
        return;
    }
    

    This will start Xvfb for headless testing before executing the tests and stop the process after testing completes.

    Edit: And make sure vendor/laravel/dusk/bin/chromedriver-linux is executable.

提交回复
热议问题