Skip to content

Commit

Permalink
Modified tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-mae committed May 30, 2024
1 parent 5a879b3 commit eb3a8da
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions playwright-tests/test_firstload.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import asyncio
from playwright.async_api import async_playwright
from playwright.sync_api import sync_playwright

async def test_title(url, expected_title):
async with async_playwright() as p:
browsers = [
("Chromium", p.chromium),
("Firefox", p.firefox),
("WebKit", p.webkit)
]
for browser_name, browser_type in browsers:
browser = await browser_type.launch()
page = await browser.new_page()
await page.goto(url)
title = await page.title()
def firstload():
with sync_playwright() as p:
for browser_type in [p.chromium, p.firefox, p.webkit]:
browser = browser_type.launch()
page = browser.new_page()
page.goto("https://joshuamae.com")
assert page.title() == "Joshua Mae"
browser.close()

assert title == expected_title, f"{browser_name} - Title does not match. Expected: {expected_title}, but got: {title}"

await browser.close()
print(f"{browser_name} - Test passed")
def main():
firstload()

if __name__ == "__main__":
url = "https://www.joshuamae.com"
expected_title = "Joshua Mae"
asyncio.run(test_title(url, expected_title))
main()

0 comments on commit eb3a8da

Please sign in to comment.