如何在需要证书验证的页面上运行 TestCafe 自动测试?

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

我需要使用 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);
});

我一运行测试,它就会加载并立即崩溃

  1. 我尝试制定解决方法并使用 www.google.com 页面搜索来模拟用户操作,但无济于事。
  2. 我尝试在开始测试时添加--ignore-certificate-errors,但也没有成功。
"testcafe chrome --ignore-certificate-error tests/1.login-test.ts", //line in my package.json file
  1. 我尝试更改主机名并通过主机名而不是IP进行申请。但也是无果而终
typescript authentication automation ssl-certificate testcafe
1个回答
0
投票

从 v3.0 开始,TestCafe 在基于 Chromium 的浏览器中默认使用 Native Automation 模式。本机自动化模式支持开箱即用的 HTTPS 和 HTTP/2 网站,因此不需要

--ssl
选项。

如果您的网站使用无效证书,您可以使用您提到的

--ignore-certificate-errors
Chrome 标志。

我相信你只是在这个标志中有一个拼写错误。请尝试使用以下命令运行测试:

testcafe "chrome --ignore-certificate-errors" test.js
© www.soinside.com 2019 - 2024. All rights reserved.