1
0
Fork 0

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
master
Dustin 2024-07-10 12:04:32 -05:00
parent 9f113d6a3f
commit 28fe49c2b2
1 changed files with 11 additions and 1 deletions

View File

@ -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)