gpt4 book ai didi

javascript - 如何在 testcafe cucumberjs 中重新加载页面

转载 作者:行者123 更新时间:2023-11-28 21:16:25 27 4
gpt4 key购买 nike

我正在将 TestCafe 与 Cucumber.js 一起使用,但我不知道如何重新加载页面。 Testcafe 文档说使用 .eval(() => location.reload(true))这给了我以下错误:

eval cannot implicitly resolve the test run in the context of which it should be executed. If you need to call eval from the Node.js API callback, pass the test controller manually via eval's .with({ boundTestRun: t }) method first. Note that you cannot execute eval outside the test code.

这是我的 BDD 场景:

When('User hard refreshes the page', async () => {
await testController
.eval(() => location.reload(true))
});

最佳答案

您可以使用 ClientFunction而不是 t.eval:

import { ClientFunction } from 'testcafe';

When('User hard refreshes the page', async () => {
const reloadPage = ClientFunction(() => location.reload(true), { boundTestRun: testController });

await reloadPage();
});

关于javascript - 如何在 testcafe cucumberjs 中重新加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57367321/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com