async def test_should_accept_single_file(page: Page, server): await page.setContent( '<input type=file oninput="javascript:console.timeStamp()">') file_chooser = (await asyncio.gather( page.waitForEvent("filechooser"), page.click("input"), ))[0] assert file_chooser.page == page assert file_chooser.element await file_chooser.setFiles(FILE_TO_UPLOAD) assert await page.evalOnSelector("input", "input => input.files.length") == 1 assert (await page.evalOnSelector( "input", "input => input.files[0].name") == "file-to-upload.txt")
async def test_should_report_downloads_with_acceptDownloads_false(page: Page, server): await page.setContent( f'<a href="{server.PREFIX}/downloadWithFilename">download</a>' ) download = (await asyncio.gather(page.waitForEvent("download"), page.click("a")))[0] assert download.url == f"{server.PREFIX}/downloadWithFilename" assert download.suggestedFilename == "file.txt" error: Optional[PlaywrightError] = None try: await download.path() except PlaywrightError as exc: error = exc assert "acceptDownloads" in await download.failure() assert error assert "acceptDownloads: true" in error.message