-
-
Save nitya/3885645ac80242775a924f3a20436136 to your computer and use it in GitHub Desktop.
Playwright Demo of Codegen - with target python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run(playwright: Playwright) -> None: | |
browser = playwright.chromium.launch(headless=False) | |
context = browser.new_context() | |
# Open new page | |
page = context.new_page() | |
# Go to https://green-stone-0ef96ef10.azurestaticapps.net/ | |
page.goto("https://green-stone-0ef96ef10.azurestaticapps.net/") | |
# Click [placeholder="Search Term..."] | |
page.click("[placeholder=\"Search Term...\"]") | |
# Fill [placeholder="Search Term..."] | |
page.fill("[placeholder=\"Search Term...\"]", "appetizer") | |
# Click text=Search | |
page.click("text=Search") | |
# Click text=Home Tags Search | |
page.click("text=Home Tags Search") | |
# Double click [placeholder="Search Term..."] | |
page.dblclick("[placeholder=\"Search Term...\"]") | |
# Fill [placeholder="Search Term..."] | |
page.fill("[placeholder=\"Search Term...\"]", "drinks") | |
# Press Enter | |
page.press("[placeholder=\"Search Term...\"]", "Enter") | |
# Click text=View Recipe | |
page.click("text=View Recipe") | |
# assert page.url == "https://green-stone-0ef96ef10.azurestaticapps.net/iced-nannari-sherbet/" | |
# Click text=Iced Nannari Sherbet Nitya N Dec 6, 2021 drinks sherbet Servings 4 Servings Prep >> i | |
with page.expect_popup() as popup_info: | |
page.click("text=Iced Nannari Sherbet Nitya N Dec 6, 2021 drinks sherbet Servings 4 Servings Prep >> i") | |
page1 = popup_info.value | |
# Close page | |
page1.close() | |
# Click i | |
page.click("i") | |
# assert page.url == "https://green-stone-0ef96ef10.azurestaticapps.net/" | |
# Close page | |
page.close() | |
# --------------------- | |
context.close() | |
browser.close() | |
with sync_playwright() as playwright: | |
run(playwright) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment