You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment it is only possible to hard wait using page.waitForTimeout(); (to my knowledge).
I have tests that consist of several requests, where i need to wait few seconds for BE to catch up, before being able to send the next one. If i dont wait some of the requests will fail, since BE wasnt given enough time to process them.
Normally i would do something like:
Request one is sent, effects of which take several seconds to change server state
Wait 3 seconds, using await page.waitForTimeout();
Request two is sent, passing because there was enough time between step 1 and 3
However, since im only sending requests, there is no "page", therefore Playwright will fail on TypeError: Cannot read properties of undefined (reading 'waitForTimeout')
I would like to have the option to have hard coded wait no matter the context (like cy.wait() for Cypress)
Ofcourse if there is better way to handle my case than hard waiting i welcome it.
Example
Im using playwright-bdd package to be able to use Cucumber gherkin syntax for scenarios and Playwright for step definition, however that should not influence the essence of the example
Then('step definition name', async ({ page, request }) => {
await wait(5000); <- This makes sure the request will pass even with slow backend
const response = await request.post(`${process.env.API_URL}/requestURL`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${global.globalData.authToken}`,
}
});
expect(response.status()).toBe(200);
const responseBody = await response.json();
expect(responseBody.response).toHaveProperty('code', 200);
expect(responseBody.response).toHaveProperty('status', 'Approved');
});
Motivation
I think there is lot of QAs that have no way to influence how quickly server state will change and simply need to use hard wait to make sure a request will be sent at the right time.
The text was updated successfully, but these errors were encountered:
You can always wait using setTimeout and promises (google it), but your test will be 100% flaky. The only way for you to work around it is to poll your server's health endpoint until you know it is live.
🚀 Feature Request
At the moment it is only possible to hard wait using
page.waitForTimeout();
(to my knowledge).I have tests that consist of several requests, where i need to wait few seconds for BE to catch up, before being able to send the next one. If i dont wait some of the requests will fail, since BE wasnt given enough time to process them.
Normally i would do something like:
await page.waitForTimeout();
However, since im only sending requests, there is no "page", therefore Playwright will fail on
TypeError: Cannot read properties of undefined (reading 'waitForTimeout')
I would like to have the option to have hard coded wait no matter the context (like cy.wait() for Cypress)
Ofcourse if there is better way to handle my case than hard waiting i welcome it.
Example
Im using playwright-bdd package to be able to use Cucumber gherkin syntax for scenarios and Playwright for step definition, however that should not influence the essence of the example
Motivation
I think there is lot of QAs that have no way to influence how quickly server state will change and simply need to use hard wait to make sure a request will be sent at the right time.
The text was updated successfully, but these errors were encountered: