microsoft / playwright-java

Java version of the Playwright testing and automation library
https://playwright.dev/java/
Apache License 2.0
1.13k stars 205 forks source link

waitForUrl behaviour #1615

Closed ThatYodaCoder closed 3 months ago

ThatYodaCoder commented 3 months ago

Hello, I am using page.waitForUrl method to wait for desired url. After clicking the submit button, I am trying to wait for url using page.waitForURL("/my-test-url/v1/foo/") but getting time out error. I see that url is caught in onResponse handler log but some how it is failing to wait. Am I using the correct method or does waitForUrl checks for only first response url it has received after form submit?

Is these any better way for do this?

Code to perform wait for url::

page.waitForURL("**/my-test-url/v1/**");

code to print all response urls:

page.onResponse(response -> System.out.println("<<" + response.status() + " " + response.url()));

Response:

<<200 https://secured.com/v1/pcs/services/browser/qreq/L/8888 
<<200 https://s3.ap-south-1.amazonaws.com/in-m/static/common/images/waiting.gif
 <<200 https://s3.ap-south-1.amazonaws.com/in-m/static/common/html/wait.htm 
 <<200 https://s3.ap-south-1.amazonaws.com/in-m/static/common/images/wait.gif 
 <<200 https://pentinelapi.com/V1/turl/2.0/qed 
 <<307 https://test-domain.com/my-test-url/v1/foo
mxschmitt commented 3 months ago

Answered here https://github.com/microsoft/playwright/issues/31507#issuecomment-2202089412