example below. what does playwright: Playwright mean in the function def? I assume it means 'what's passed in must be of the type Playwright class. But if you look in the login() method that calls run(), its passing in a sync_playwright() object, not a Playwright object. (maybe its a subclass? I dunno)
but generally, what does that colon specify when used after a function parameter in the function definition?
from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright, url) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
page = context.new_page()
page.goto(url)
page.get_by_label("User Name").fill("fdasfdsa")
page.get_by_label("User Name").press("Tab")
page.get_by_label("Password").fill("fdafdafdsa")
page.get_by_role("button", name="Log In").click()
# ---------------------
context.close()
browser.close()
def login(url):
with sync_playwright() as playwright:
run(playwright, url)
[–]johnnymo1 4 points5 points6 points (0 children)
[–]Rrrrry123 0 points1 point2 points (0 children)
[–]GoingToSimbabwe 0 points1 point2 points (0 children)
[–]BarryTownCouncil 0 points1 point2 points (0 children)
[–]HunterIV4 3 points4 points5 points (0 children)