如何在chrome docker镜像上从本地运行testcafe?

问题描述 投票:0回答:1

我不想安装chrome来运行testcafe,想使用chrome的docker镜像。

docker run -d -p 4444:4444 selenium/standalone-chrome

第二步:

docker container ls
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                    NAMES
3487d6a08310        selenium/standalone-chrome   "/opt/bin/entry_poin…"   About an hour ago   Up About an hour    0.0.0.0:4444->4444/tcp   charming_proskuriakova

第三步:这段代码可以在python2.7中使用。

from selenium import webdriver

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver=webdriver.Remote(
          command_executor='http://0.0.0.0:4444/wd/hub',
          desired_capabilities=DesiredCapabilities.CHROME)


driver.get("https://www.google.com/")  
print driver.title
driver.close() 

我希望在testcafe中使用同样的功能。基本代码(test1.js)。

    import { Selector } from 'testcafe';

    fixture `Getting Started`
        .page `http://devexpress.github.io/testcafe/example`;

    test('My first test', async t => {
        // Test code
});

在本地Chrome浏览器上执行。

testcafe chrome test1.js

我正在寻找用docker镜像替换chrome的方法。我知道,chrome是testcafe内置的,你可以考虑用 "safari "或者其他浏览器来代替chrome。我的想法是学会在testcafe中使用docker镜像。PS:我不想使用testcafetestcafe镜像,因为我的问题不是在docker中运行testcafe,而是在docker中只运行浏览器。

docker testing automated-tests e2e-testing testcafe
1个回答
1
投票

请你说明一下为什么不使用testcafe的docker镜像?  似乎seleniumstandalone-chrome镜像也包含了selenium相关的代码,这些代码会监听api请求并在容器内的浏览器上运行测试。

注意:testcafe没有内置浏览器,它运行的是本地安装的浏览器。

另一种在docker镜像中运行浏览器的方法是使用远程浏览器功能(https:/devexpress.github.iotestcafedocumentationusing-testcafecommand-line-interface.html#remote-browsers。). 你需要使用 "远程 "浏览器别名运行tescafe,然后通过 "docker run "命令在容器内运行浏览器,并将 "http:/browserconnect "链接传递给它。

© www.soinside.com 2019 - 2024. All rights reserved.