自从2023年底playwright框架火起来之后,很多小伙伴都会来咨询我们这个框架相关内容,甚至问我们什么时候出这个课程。
这不,新课程终于在大家的千呼万唤中出来啦!具体的课程大纲和试听视频!
Web自动化测试项目实战(Pytest+Playwright框架):
Playwright技术:与selenium框架方案对比与优势分析 |
Playwright技术:安装、常见搭建问题详解 |
Playwright技术:运行原理。Websocket底层操作协议讲解 |
Playwright技术:获取页面title。刷新/关闭页面、截屏 |
Playwright技术:Locator对象API, Page对象API |
Playwright技术:iframe进入、等待技术 |
Playwright技术:同步和异步API介绍 |
Playwright技术:单选框、多选框。复选框操作。下拉框选择 |
元素定位失败分析 |
今天给大家分享一下playwright的安装和一些常用API,为后续的学习做好准备工作。
Playwright安装
API
内容管理器PlaywrightContextManager
浏览器类型BrowserType
浏览器类型BrowserType
浏览器对象browser
页面对象Page
1 page = browser.new_page()
2 #源码
3 def new_page(
4 self,
5 *,
viewport: ViewportSize = None,
6 screen: ViewportSize = None,
7 no_viewport: bool = None,
8 ignore_https_errors: bool,
9 java_script_enabled: bool = None,
10 bypass_csp: bool = None,
11 user_agent: str = None,
12 locale: str = None,
13 timezone: str = None,
14 geolocation: Geolocation = None,
15 permissions: typing.List[str] = None,
16 extra_http_headers: typing.Optional[typing.Dict[str, str]] = None,
17 offline: bool = None,
18 http_credentials: HttpCredentials = None,
19 device_scale_factor: float = None,
20 is_mobile: bool = None,
21 has_touch: bool = None,
22 color_scheme: Literal["dark", "light", "no-preference"] = None,
23 forced_colors: Literal["active", "none"] = None,
24 reduced_motion: Literal["no-preference", "reduce"] = None,
25 accept_downloads: bool = None,
26 default_browser_type: str = None
27 proxy: ProxySettings = None,
28 record_har_path: typing.Union[str, pathlib.Path] = None,
29 record_har_omit_content: bool = None,
30 record_video typing.Union[str, pathlib.Path] = None,
31 record_video_size: ViewportSize = None,
32 storage_state: typing.Union[StorageState, str, pathlib.Path] = None,
33 base_url: str = None, )
34
35 strict_selectors: bool = None
36 "Page":
定位locator
定位Element
鼠标操作
元素对象Locator
上面就是playwright的安装和一些常用API介绍,你学会了吗?