如何在TestCafe中重新加载当前页面?旧方法报错无法使用
Hey there! I’ve dealt with this exact frustration when updating TestCafe—those old .eval() hacks stop working once you move to newer versions. Let’s get you sorted with the proper way to reload the page now.
The Correct, Up-to-Date Method
TestCafe now has a built-in t.reload() action that replaces the old location.reload(true) eval trick. It’s designed specifically for test workflows and avoids the "no function" errors you’re seeing.
Here’s how to use it, including the option to ignore cache (which matches the true parameter in your old code):
await t.reload({ ignoreCache: true });
Why Your Old Code Broke
Newer TestCafe versions deprecated the direct .eval() method on selectors (or adjusted the API structure) because it bypassed some of TestCafe’s built-in test safeguards. The t.reload() action is the official, supported way to trigger a page reload now—it integrates smoothly with TestCafe’s test execution flow and is more reliable.
If you need to reload in a specific context (like after an action), just drop that line right into your test sequence where you want the reload to happen.
内容的提问来源于stack exchange,提问作者ingo

