转到上一页的“ alt + left”不适用于testcafe,但可以手动正常运行

ari*_*ria 3 javascript testing automated-tests accessibility testcafe

我正在尝试TestCafe使用以下代码从现有页面返回上一页:

await t.pressKey('alt+left');
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用。页面没有变化。但是,当我在浏览器中进行验证时,手动进行似乎可以正常工作。

有人可以帮我这个忙,我希望能够仅使用键盘击键返回上一页。

mlo*_*sev 6

TestCafe不支持alt+left按键组合(请参阅此处的支持的按键组合列表)。

您可以使用浏览器的History API在页面之间导航。

看一个例子:

import { Selector, ClientFunction } from 'testcafe';

fixture `Fixture`
  .page `https://devexpress.github.io/testcafe/`;

const back = ClientFunction(() => window.history.back());

test('test', async t => {
    await t.navigateTo('https://devexpress.github.io/testcafe/documentation/getting-started/');

    await back();
});
Run Code Online (Sandbox Code Playgroud)