我不想安装chrome来运行testcafe,而是想使用chrome docker镜像。Step1:
docker run -d -p 4444:4444 selenium/standalone-chromeStep2:
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_proskuriakovaStep3:此代码适用于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我正在寻找一种方法,以取代铬与码头图像。我知道,chrome是内置了testcafe的,你可以考虑使用"safari“或者其他浏览器来代替chrome。IDea正在学习如何在testcafe中使用docker镜像。PS:我不想使用testcafe/testcafe镜像,因为我的问题不是在docker中运行testcafe,而是只在docker中运行浏览器。
发布于 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'链接
https://stackoverflow.com/questions/61339454
复制相似问题