[Question] How to wait for multiple responses ?
See original GitHub issueIn js I can do this
async waitForFindingUpload(findingName) {
return await this.page.waitForResponse(async (response) => {
const body = await response.text();
return body.includes(findingName)
});
}
const responses = await Promise.all([
this.waitForFindingUpload("Name of Finding 1"),
this.waitForFindingUpload("Name of Finding 2"),
this.#uploadFile()
])
How to do the same in java ? Your API suggests this waiting mechanism:
Response res = page.waitForResponse(response -> {
return response.url().equals("https://url_/gateway/graphql") &&
response.request().postData().contains("sidebar");
}, () -> {
page.click("//button[@type='submit']");
});
this way I can wait only for 1 response
I tried just several waiting in a row after click on a button:
page.click("//button[@type='submit']");
page.waitForResponse()
page.waitForResponse()
page.waitForResponse()
page.waitForResponse()
page.waitForResponse()
and not all of them are resolved. For example after page loaded there are 5 graphql responses, 3-4 consequent waits are resolved I guess based on timings.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to wait for multiple fetch responses to be pushed in array ...
You can wait for all the promises with Promise.all . I used map instead of forEach to map all array values to promises....
Read more >wait for all responses to multiple calls - MuleSoft Help Center
Hello: I am developing a flow in which I have to call n times to the same external system. Each call is synchronous,...
Read more >How long should we wait after asking a question? - Byrdseed
Hopefully obvious, though: you need to ask interesting, higher-order questions in order to get multiple, thoughtful responses. No matter how long you wait, ......
Read more >Wait Time: Making Space for Authentic Learning
First, wait time 1 constitutes a 3-5 second pause between asking a question and soliciting an answer. Second, wait time 2 is a...
Read more >How to Join Multiple Requests in JavaScript with Promise
Why is this helpful? In this case we need to make two requests, wait for them both to be completed, and then pass...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can have nested
waitForResponse
calls:Or alternatively you can always use
page.onResponse()
that will be called for all responses.Hope it answers your question.
thanks for this @yury-s . I had to make a small change to the if statement because it was throwing an index out of bounds exception. For anyone else reading this here is how I modified it: