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("http://psamv4athetn.cminl.oa/form/Logon.html?url=http%3A%2F%2Fpinnoplm.cminl.oa%2Freport%2FpartBom%2FbomStructure%2FbomWithMaker&SysID=INNOPLM") page.locator("input[type=\"text\"]").click() page.locator("input[type=\"text\"]").fill("qilong.zou") page.locator("input[type=\"text\"]").press("Tab") page.locator("#tbPassword").fill("pass.007") page.locator("#tbPassword").press("Enter") page.get_by_role("link", name=" Report ").click() page.get_by_role("link", name="Part/BOM ").click() page.get_by_role("link", name="BOM With Maker").click() page.locator("#parentPartNo").click() page.locator("#parentPartNo").press("CapsLock") page.locator("#parentPartNo").fill("6B01M003A300R") page.get_by_role("button", name=" 查詢").click() with page.expect_download() as download_info: page.get_by_role("button", name="").click() download = download_info.value # --------------------- context.close() browser.close() with sync_playwright() as playwright: run(playwright) 這個有什麽問題嗎
时间: 2023-04-09 12:02:21 浏览: 211
playwright-video::clapper_board:保存Playwright页面的视频
这段代码是使用Python编写的,使用了Playwright库来自动化测试网页。其中,从Playwright库中导入了Playwright、sync_playwright和expect三个模块。函数run()接受一个Playwright对象作为参数,然后使用该对象启动了一个Chromium浏览器,并创建了一个新的上下文和页面。最后,页面跳转到了"http://psamv4athetn.cminl.oa/form/Logon.html?url=http://pinnoplm.cminl.oa/report/partBom/bomStructure/bomWithMaker"这个网址。
阅读全文