首页 媒体聚焦 > 正文

实例讲解Playwright(二)_最新快讯

2023-04-19 08:15:23 来源:博客园

实例讲解Playwright(二)

网址说明
https://playwright.dev/官网首页
https://playwright.dev/python/docs/introPython部分入口
https://github.com/microsoft/playwright-pythongithub,python入口
https://github.com/microsoft/playwright-python/releasespython部分的release notes

本文基于 playwright 1.32.1 发布于 2023-3-30转载请注明出处,这是第二篇学习前你得有html、css、xpath等基础,最好有selenium基础,我是对比来讲解的


(资料图片仅供参考)

④Page|Locator对象能力

自动等待

案例

特性

截图

这部分能力,页面对象有,元素对象也有

页面截图

全屏

元素截图

bytes对象

键盘操作

鼠标操作

单击、双击、右击

from playwright.sync_api import sync_playwrightwith sync_playwright() as pw:    browser = pw.chromium.launch(headless=False)      page = browser.new_page()      page.goto("http://sahitest.com/demo/clicks.htm")    page.locator("[value="dbl click me"]").dblclick()    page.locator("[value="click me"]").click()    page.locator("[value="right click me"]").click(button="right")    page.wait_for_timeout(5000)

悬停

拖拽

Alert对话框

alert处理

confirm处理

prompt处理

消息文本的输出

frame切换

window管理

文件上传

input类型单文件上传

非input类型的文件上传

多文件上传

上一篇:

下一篇:

x
媒体聚焦