Is there a way to pass arguments into a playwright test in python? I want to be able to check a certain string appears on the browser screen, but this string is variable.
e.g. if i call the test script with "pytest testscript.py --expectedString test123"
where abouts would the argument go in the test script?
from playwright.sync_api import sync_playwright, Page, expect
import re
def test():
playwright = sync_playwright().start()
chromium = playwright.chromium # or "firefox" or "webkit".
browser = chromium.launch(headless=False) # TODO remove this later
page = browser.new_page()
page.goto("https://playwright.dev/")
# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("Playwright"))
# create a locator
get_started = page.get_by_role("link", name="Get started")
# Expect an attribute "to be strictly equal" to the value.
expect(get_started).to_have_attribute("href", "/docs/intro")
# Click the get started link.
get_started.click()
# Expects the URL to contain intro.
expect(page).to_have_url(re.compile(".*intro"))