【发布时间】:2020-08-03 23:00:23
【问题描述】:
我不想安装 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
Step3:此代码适用于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。 IDea 在 testcafe 中学习使用 docker 镜像。 PS:我不想使用 testcafe/testcafe 图像,因为我的问题不是在 docker 中运行 testcafe,而只是在 docker 中运行浏览器。
【问题讨论】:
标签: docker testing automated-tests e2e-testing testcafe