# Properly using Wait for Response

**URL:** <https://forum.robotframework.org/t/properly-using-wait-for-response/4507>\
**Category:** Browser\
**Created:** [12 August 2022 13:14 UTC](https://forum.robotframework.org/t/properly-using-wait-for-response/4507 "2022-08-12T13:14:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatrickZerbinatti](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@PatrickZerbinatti](https://forum.robotframework.org/u/PatrickZerbinatti)\
**Post date:** [12 August 2022 13:14 UTC](https://forum.robotframework.org/t/properly-using-wait-for-response/4507/1 "2022-08-12T13:14:34Z")

</div>

Hello Guys my first post here,

Basically I have the following situation, I need to automate a website that has some buttons on click refresh the page and put new info on a table.  
So, I need to do a Click and wait until the response of this action.

I know the “Wait for response” keyword, but I fell like I am not understanding it, basically can you guys explain to me the diference between this two codes:

```
Click ${button}
Wait for Response

```

And

```
${promise} = Promise To Wait For Response
Click ${button}
Wait For ${promise}

```

What is the most correct? (if there is one)

---

<div class="post-metadata">

**Author:** ![mkorpela](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/mkorpela/32/33_2.png) [@mkorpela](https://forum.robotframework.org/u/mkorpela)\
**Post date:** [12 August 2022 17:48 UTC](https://forum.robotframework.org/t/properly-using-wait-for-response/4507/2 "2022-08-12T17:48:00Z")

</div>

There is a possibility that the click related request response happens before you attach the wait if wait is done after. So with the _Promise To_ is more correct.

---

<div class="post-metadata">

**Author:** ![PatrickZerbinatti](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@PatrickZerbinatti](https://forum.robotframework.org/u/PatrickZerbinatti)\
**Post date:** [12 August 2022 18:17 UTC](https://forum.robotframework.org/t/properly-using-wait-for-response/4507/4 "2022-08-12T18:17:47Z")

</div>

Got it, but when I only use like this, seems like the promise don’t take the right response, because the “Wait for” simply pass and don’t wait the response of the button.  
Any tip? How to catch the right response for this case?

---

<div class="post-metadata">

**Author:** ![mkorpela](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/mkorpela/32/33_2.png) [@mkorpela](https://forum.robotframework.org/u/mkorpela)\
**Post date:** [13 August 2022 07:39 UTC](https://forum.robotframework.org/t/properly-using-wait-for-response/4507/5 "2022-08-13T07:39:28Z")

</div>

You need to restrict the requests with the url they are calling [https://marketsquare.github.io/robotframework-browser/Browser.html#Wait%20For%20Response](https://marketsquare.github.io/robotframework-browser/Browser.html#Wait%20For%20Response)

I would check from developer console network tab in the browser what traffic there is and choose the correct package url.

---

<div class="post-metadata">

**Author:** ![edsherwin](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/edsherwin/32/3011_2.png) [@edsherwin](https://forum.robotframework.org/u/edsherwin)\
**Post date:** [13 March 2024 12:22 UTC](https://forum.robotframework.org/t/properly-using-wait-for-response/4507/7 "2024-03-13T12:22:25Z")

</div>

I have something similar scenario and I couldn’t get the expected output and move to the next action. Will appreciate for help. Thanks

```
# This will continue to the next operation after ${promise} criteria is met 
Click ${open_selected}
Wait For ${promise}

`Click ${new_version}
# Click ${new_version} will initiate to check the calculations_status
Click ${open_selected} # This will catch the status of isCalculating
### The response to wait
# endpoint: https://{url}/api/v1/gateway/costing_versions/100171845/calculations_status
# response: {"isCalculating":false} # isCalculating should set to false to continue on next operation or click button
${promise} = Promise To Wait For Response async (response) => response.url().endsWith(calculations_status') && response.status() === 200 && (await response.text()).includes('false')

# This will continue to the next operation after ${promise} criteria is met 
Click ${open_selected}
Wait For ${promise}`

```
