想和docker alpine做黄昏测试 [英] want to do dusk test with docker alpine

查看:88
本文介绍了想和docker alpine做黄昏测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在尝试在docker alpine内部测试laravel/dusk. 但是当我设置时,遇到了以下错误.

now trying to test laravel/dusk inside docker alpine. but when I set up, met the following error.

Facebook \ WebDriver \ Exception \ WebDriverCurlException:抛出了卷曲错误 使用参数将http POST发送到/session: {"desiredCapabilities":{"browserName":"phantomjs","platform":"ANY"}}

Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"phantomjs","platform":"ANY"}}

无法连接到本地主机端口4444:连接被拒绝

Failed to connect to localhost port 4444: Connection refused


源代码设置如下. tests/DuskTestCase.php


source code setting is the followings. tests/DuskTestCase.php

<?php

namespace Tests;

use Laravel\Dusk\TestCase as BaseTestCase;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;

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()
     {
         return RemoteWebDriver::create(
             'http://localhost:4444/wd/hub', DesiredCapabilities::phantomjs()
         );
     }
}

非常感谢您阅读.

推荐答案

这确实是事情的结合.您需要覆盖Dusk随附的chromedriver-linux二进制文件,因为它与高山图像不兼容. 在您的Dockerfile中应该看起来像这样:

It is a combination of things really. You need to overwrite the chromedriver-linux binary that is shipped with Dusk, because it is not compatible with the alpine image. It should look something like this in your Dockerfile:

RUN apk update && apk upgrade \
    && echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
    && echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
    && apk add --no-cache \
    chromium@edge \
    chromium-chromedriver@edge \
    xvfb \
    nss@edge \
    && rm -rf /var/lib/apt/lists/* \
    /var/cache/apk/* \
    /usr/share/man \
    /tmp/*

RUN rm /var/www/html/vendor/laravel/dusk/bin/chromedriver-linux \
&& ln -s /usr/bin/chromedriver /var/www/html/vendor/laravel/dusk/bin/chromedriver-linux \ 
&& ln -s /usr/bin/chromium-browser /usr/bin/chrome

在您的start.sh中,您使用:

In your start.sh you use:

Xvfb :99 &
RUN export DISPLAY=:99

这将启动无头显示,因此chrome实际上可以在容器内无头运行.

This will start a headless display so chrome can actually run headless inside your container.

这篇关于想和docker alpine做黄昏测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆