Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Created May 9, 2024 12:15
Show Gist options
  • Save SarahElson/b945c10adb3b644d154ee9cbb580865e to your computer and use it in GitHub Desktop.
Save SarahElson/b945c10adb3b644d154ee9cbb580865e to your computer and use it in GitHub Desktop.
How to Use Playwright Wait For Navigation Methods
from playwright.sync_api import expect
from fixtures.wait_fixture import page, browser, set_test_status
import re
def test_wait_url_navigation(page, set_test_status):
page.goto("https://ecommerce-playground.lambdatest.io/")
page.get_by_role("link", name="Blog", exact=True).click()
# waits for navigated url to match url argument
page.wait_for_url("**/blog/home")
title = page.title()
if "Blog - Poco theme" in title:
set_test_status(status="passed", remark="Title matched")
else:
set_test_status(status="failed", remark="Title did not match")
expect(page).to_have_url(re.compile(".*/blog/home$"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment