我想在 testcafestudio 中重复流程。
如何才能运行10~1000次1flow?
我想知道以下两件事:
似乎无法在 testcafestudio 中重复流程,但我需要这样做,以便重复测试。
您可以使用 JavaScript 测试文件格式多次重复测试 (https://docs.devexpress.com/TestCafeStudio/401052/test-concepts/test-scripts)。还可以以 JavaScript 测试文件格式记录测试。
以下解决方法允许您多次重复测试:
import from 'testcafe';
function testWrapper (name, cb, repeat = 5) {
for (let index = 0; index < repeat; index++)
test(name, cb);
}
fixture('Getting Started')
.page('https://devexpress.github.io/testcafe/example');
testWrapper('My first test', async t => {
await t
.typeText('#developer-name', 'John Smith')
.click('#submit-button')
.expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});
如果您在无代码模式下运行测试,您也可以执行相同的操作 - 只需首先将测试转换为 JavaScript。