我正在尝试从我的 TestCafe
代码中的现有页面返回到上一页:
await t.pressKey('alt+left');
但这似乎行不通。页面没有变化。但是当我在浏览器中手动验证时,它似乎工作正常。
谁能帮我解决这个问题,我希望能够仅使用键盘敲击返回到上一页。
最佳答案
TestCafe 不支持 alt+left
组合键(请参阅支持的组合键列表 here)。
您可以使用浏览器的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();
});
关于javascript - 用于转到上一页的“alt+left”不适用于 testcafe,但手动工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57248642/