-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpyppeteer_test.py
More file actions
32 lines (29 loc) · 987 Bytes
/
pyppeteer_test.py
File metadata and controls
32 lines (29 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import asyncio
import time
import sys
from pyppeteer import launch
async def main():
# launch chromium browser in the background
browser = await launch(executablePath="/usr/bin/google-chrome-stable", headless=True)
# open a new tab in the browser
page = await browser.newPage()
filename = os.path.join(os.getcwd(), "build/index.html")
print(f"filename is {filename}")
file_url = f"file://{filename}"
print(f"going to open {file_url}")
# add URL to a new page and then open it
await page.goto(file_url)
time.sleep(10)
selector = "ul.solr-search-fields"
search_fields = await page.querySelector(selector)
print(f"search fields are {search_fields}")
if search_fields is None:
print("Did not find solr search fields, build is bad!")
sys.exit(1)
else:
print("Success")
# close the browser
await browser.close()
print("Starting...")
asyncio.get_event_loop().run_until_complete(main())