我需要使用 TestCafe 在需要证书验证的页面上运行自动测试。 在我的 .testcaferc.json 文件中,我添加了 SSL 证书,当我运行测试时,首先在 Chrome 窗口中要求我确认连接不安全,我手动接受它,然后我被重定向到 localhost,其中一段时间后,在 URL-TestCafe Chrome 的地址中,我看到 https://localhost:4200/about:error 之后我的测试在一段时间后重新启动,但也没有给出任何错误
这是我的代码示例
fixture (`Info Page test`).page('www.google.com');
const infoPage = new InfoPage();
test('Check label on Info Page', async () => {
await t.navigateTo('IP url')
await t.wait(10000);
});
我一运行测试,它就会加载并立即崩溃
"testcafe chrome --ignore-certificate-error tests/1.login-test.ts", //line in my package.json file
从 v3.0 开始,TestCafe 在基于 Chromium 的浏览器中默认使用 Native Automation 模式。本机自动化模式支持开箱即用的 HTTPS 和 HTTP/2 网站,因此不需要
--ssl
选项。
如果您的网站使用无效证书,您可以使用您提到的
--ignore-certificate-errors
Chrome 标志。
我相信你只是在这个标志中有一个拼写错误。请尝试使用以下命令运行测试:
testcafe "chrome --ignore-certificate-errors" test.js