You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在TestCafe中重新加载当前页面?旧方法报错无法使用

Fix for Reloading Page in Newer TestCafe Versions

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:30:18