首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在chrome docker镜像上从本地运行testcafe

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

Stack Overflow用户
提问于 2020-04-21 16:49:14
回答 1查看 732关注 0票数 0

我不想安装chrome来运行testcafe,而是想使用chrome docker镜像。Step1:

代码语言:javascript
复制
docker run -d -p 4444:4444 selenium/standalone-chrome

Step2:

代码语言:javascript
复制
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

Step3:此代码适用于python2.7

代码语言:javascript
复制
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):

代码语言:javascript
复制
    import { Selector } from 'testcafe';

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

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

在本地Chrome上执行:

代码语言:javascript
复制
testcafe chrome test1.js

我正在寻找一种方法,以取代铬与码头图像。我知道,chrome是内置了testcafe的,你可以考虑使用"safari“或者其他浏览器来代替chrome。IDea正在学习如何在testcafe中使用docker镜像。PS:我不想使用testcafe/testcafe镜像,因为我的问题不是在docker中运行testcafe,而是只在docker中运行浏览器。

EN

回答 1

Stack Overflow用户

发布于 2020-04-23 00:15:02

您能澄清一下为什么不使用testcafe docker镜像吗?似乎selenium/standalone-chrome镜像也包含selenium相关的代码,这些代码监听api请求并在安装在容器内的浏览器上运行测试。

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

在docker镜像中运行浏览器的另一种方法是使用远程浏览器功能(https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#remote-browsers). You将需要使用' remote‘浏览器别名运行tescafe,然后通过'docker run’命令在容器内运行浏览器,并向其传递'http:///browser/connect'链接

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61339454

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档