最强自动化测试框架Playwright(9)- 下载文件_playwright下载文件-CSDN博客
from playwright.sync_api import sync_playwright def run(playwright): chromium = playwright.chromium browser = chromium.launch(headless=False, slow_mo=3000) page = browser.new_page() page.goto(r'download.html') with page.expect_download() as download_info: page.get_by_text("点我下载").click() download = download_info.value print(download.page) # wait for download to complete print(download.url) # 获取下载的url地址 # 这一步只是下载下来,生成一个随机uuid值保存,代码执行完会自动清除 print(download.path()) # 最终可以用save_as 保存到本地 download.save_as(download.suggested_filename) browser.close() with sync_playwright() as playwright: run(playwright)
标签:playwright,Python,sync,Playwright,download,chromium,page,下载 From: https://www.cnblogs.com/daizichuan/p/18176962