如何期望URL在TestCafe中被重定向?

Kno*_*our 6 testing redirect automated-tests e2e-testing testcafe

单击第一个需要登录的内容时,我想检测URL重定向到登录页面。

有什么办法可以实现?

小智 5

这是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');
});
Run Code Online (Sandbox Code Playgroud)