Skip to content

Commit

Permalink
adding basic test example script
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtlmoon committed Feb 7, 2024
1 parent dc2165d commit 4d2ee8d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyppeteer
memory_profiler
26 changes: 26 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/python3
import time

import pyppeteer
import asyncio

loop = asyncio.get_event_loop()
async def goto_page_url(url):
browser = await pyppeteer.launcher.connect(
loop=loop,
browserWSEndpoint='ws://localhost:3000'
)
page = await browser.newPage()
await page.goto(url)
content = await page.content()
assert 'html' in content.lower(), "'html' should exist in the page fetch"
await page.close()
await browser.close()

if __name__ == '__main__':

async def main():
now = time.time()
await asyncio.create_task(goto_page_url(url="https://google.com"))
print (f"Done in {time.time()-now:.2f} seconds")
loop.run_until_complete(main())

0 comments on commit 4d2ee8d

Please sign in to comment.