Quantcast
Viewing all articles
Browse latest Browse all 14040

Regex is not working in Python Playwright page.wait_for_url()?

I found a strange difference in Python VS JavaScript regex implementation of page.waitForURL() / page.wait_for_url().

In python version this code doesn't work:

from playwright.sync_api import sync_playwrightwith sync_playwright() as p:    browser = p.chromium.launch()    page = browser.new_page()    page.goto("https://playwright.dev/python/docs/api/class-page")    page.wait_for_url(r"docs/api")    browser.close()

In JavaScript version it works fine:

// @ts-checkconst playwright = require('playwright');(async () => {  // Try to add 'playwright.firefox' to the list ↓  for (const browserType of [playwright.chromium, playwright.webkit]) {    const browser = await browserType.launch();    const context = await browser.newContext();    const page = await context.newPage();    await page.goto('https://playwright.dev/python/docs/api/class-page');    await page.waitForURL(/docs\/api/);    await browser.close();  }})();

Viewing all articles
Browse latest Browse all 14040

Trending Articles