我正在将 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/