Reputation: 165
This is a kind of test I am trying to run in test cafe v1.0.1, I am relatively new to this.
This my test.js file where I have three different test cases R03, R05, R06 each after clicking on the SUBMIT button downloads an EXCEL file.
But before the download is finished, the browser closes and moves on to the next test.
How can I let the browser wait until the document is downloaded before moving onto the next test (say r05 in my case)?
import { Selector } from 'testcafe';
fixture `First Fixture`
.page `http://devexpress.github.io/testcafe/example`;
test('R03', async t => {
await t
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Year_1'))
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Location_1'))
.click(Selector('span').withText('SUBMIT'))
});
test('R05', async t => {
await t
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Year_2'))
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Location_2'))
.click(Selector('span').withText('SUBMIT'))
});
test('R06', async t => {
await t
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Year_3'))
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Location_3'))
.click(Selector('span').withText('SUBMIT'))
});
Upvotes: 2
Views: 1722
Reputation:
Not the ideal solution, but simple and should work if set the appropriate wait time.
test('R03', async t => {
await t
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Year_1'))
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Location_1'))
.click(Selector('span').withText('SUBMIT'))
.wait(60000); // in ms
});
Another solution would be writing a function to check if the file exists in the directory -- see answers here
Upvotes: 4