-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a879b3
commit eb3a8da
Showing
1 changed file
with
12 additions
and
21 deletions.
There are no files selected for viewing
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
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() |