提问人:Gomez Gomez 提问时间:10/31/2023 更新时间:10/31/2023 访问量:25
使用 Playwright Inspector 从 Chromium 打印 PDF(Python)
Printing PDF from Chromium using Playwright Inspector(Python)
问:
因此,我正在尝试在 Chromium 浏览器中使用带有 Playwright 检查器的 python 执行 pdf 的打印。代码执行后,打开最后一个行项目“page1.locator(”#submitter“).click()”PDF 窗口,当我单击打印图标时,Playwright 检查器无法识别或记录该窗口的打印过程,然后选择打印机,然后选择按钮打印。这是我的代码,只是在寻找有关如何打印或保存在新窗口中打开的 pdf 的建议?Chromium 中弹出的 pdf 窗口称为“Locator(”embed“)”,它也有一个 http 地址。如果需要,我可以提供更多详细信息。
from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
page = context.new_page()
page.goto("https://system.fakewebsite.com/pages/customerlogin.jsp")
page.get_by_placeholder("Email address").click()
page.get_by_placeholder("Email address").fill("faslse@gmail")
page.get_by_placeholder("Password").click()
page.get_by_placeholder("Password").fill("false")
page.get_by_role("button", name="Log In").click()
page.wait_for_load_state("networkidle")
page.get_by_role("row", name="PRODUCTION Choose account", exact=True).get_by_role("link").click()
page.wait_for_load_state("networkidle")
page.get_by_placeholder("6-digit code").fill("335502")
page.get_by_label("Submit").click()
page.wait_for_load_state("networkidle")
page.get_by_role("link", name="Reports", exact=True).click()
page.wait_for_load_state("networkidle")
page.get_by_role("link", name="Payments : by Cashier").click()
page.wait_for_load_state("networkidle")
page.get_by_role("link", name="INV0000000").click()
page.wait_for_load_state("networkidle")
page.get_by_role("link", name="Invoice").click()
page.wait_for_load_state("networkidle")
page.get_by_role("link", name="License #LIC0000000").click()
page.wait_for_load_state("networkidle")
with page.expect_popup() as page1_info:
page.locator("#custpage_print_button").click()
page.wait_for_load_state("networkidle")
page1 = page1_info.value
page1.get_by_role("row", name="License", exact=True).get_by_role("radio").check()
page1.locator("#submitter").click()
with sync_playwright() as playwright:
run(playwright)
答: 暂无答案
评论