Skip to content

Commit

Permalink
Async test
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-mae committed May 30, 2024
1 parent 3dfe6e1 commit 9547c7f
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions playwright-tests/test_firstload.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
from playwright.sync_api import sync_playwright
import pytest
from playwright.async_api import async_playwright

def test_firstload(browser_type):
with sync_playwright() as p:
browser = getattr(p, browser_type).launch(headless=False)
page = browser.new_page()
page.goto("https://joshuamae.com")
title = page.title()
assert title == "Joshua Mae", f"Title was '{title}', but expected 'Joshua Mae'"
browser.close()

def main():
browsers = ["chromium", "firefox", "webkit"]
for browser_type in browsers:
print(f"Testing on {browser_type}...")
test_example(browser_type)

if __name__ == "__main__":
main()
@pytest.mark.parametrize("browser_name", ["chromium", "firefox", "webkit"])
async def test_firstload(browser_name, browser_type, context):
browser = await browser_type.launch()
page = await context.new_page()
await page.goto("https://joshuamae.com")
title = await page.title()
assert title == "Joshua Mae", f"Title was '{title}', but expected 'Joshua Mae'"
await browser.close()

0 comments on commit 9547c7f

Please sign in to comment.