xactfetch: Save Playwright trace for failed runs
Playwright has a nifty feature called the [Trace Viewer][0], which you can use to observe the state of the page at any given point during the browsing session. This should make troubleshooting failures a lot easier. [0]: https://playwright.dev/python/docs/trace-viewer-intro
This commit is contained in:
12
xactfetch.py
12
xactfetch.py
@@ -722,7 +722,9 @@ async def amain() -> None:
|
||||
failed = False
|
||||
async with async_playwright() as pw, secrets:
|
||||
browser = await pw.chromium.launch(headless=False)
|
||||
page = await browser.new_page()
|
||||
context = await browser.new_context()
|
||||
await context.tracing.start(screenshots=True, snapshots=True)
|
||||
page = await context.new_page()
|
||||
banks = sys.argv[1:] or list(ACCOUNTS.keys())
|
||||
if 'commerce' in banks:
|
||||
if not await download_commerce(
|
||||
@@ -734,6 +736,14 @@ async def amain() -> None:
|
||||
page, secrets, end_date, token, importer
|
||||
):
|
||||
failed = True
|
||||
if failed:
|
||||
await context.tracing.stop(path='trace.zip')
|
||||
with open('trace.zip', 'rb') as f:
|
||||
await ntfy(
|
||||
'Downloading one or more transaction lists failed.',
|
||||
attach=f.read(),
|
||||
filename='trace.zip',
|
||||
)
|
||||
raise SystemExit(1 if failed else 0)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user