I have I question about Playwright. When I make a request to a website with "page.goto("example_url.com")"
Using page.on("response", lambda res: print(res.status))
It returns to me more than one response.
My question is how do I deal with this kind of situation to determine if the page has responded to me successfully.
page.goto returns the Response of the page where its navigating to. So you can do something like that:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
response = page.goto("http://whatsmyuseragent.org/")
assert response.ok
browser.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With