单击需要先登录的内容时,我想检测 URL 是否被重定向到登录页面。
有没有办法做到这一点?
这是 testcafe v0.16.x 的解决方案。您可以使用ClientFunction
获取页面的网址:
import { ClientFunction, t } from 'testcafe';
fixture `check url`
.page `http://example.com`;
test('check url', async t => {
const getLocation = ClientFunction(() => document.location.href);
await t.expect(getLocation()).contains('example.com');
});