From 9a83cf3de55163a4bfaf5f906cb3025987adc58e Mon Sep 17 00:00:00 2001 From: zhouyuan63 Date: Tue, 12 Nov 2024 15:26:01 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96cook?= =?UTF-8?q?ie=E7=9A=84=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/guide/exam/problem.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/guide/exam/problem.md b/docs/guide/exam/problem.md index 9a17890..30c6afa 100644 --- a/docs/guide/exam/problem.md +++ b/docs/guide/exam/problem.md @@ -8,3 +8,25 @@ await page.setBrowserCofing({ignoreHTTPSErrors:true}) // ....其他代码 ``` + +## 获取playwright原生控件 + +获取pw原生控件可以加强对页面操作的定制化, `yintao` 通过对pw进行封装来自动完成调度。 + +结构如下,可通过`page.control` 来获取 `TestControl` 对象. [更多用法参考](https://playwright.dev/docs/api/class-browsercontext#browser-context-cookies) + +```js +class TestControl { + runContext: Page | Frame | undefined + browserContext: BrowserContext | undefined + currentPage: Page | undefined + browser: Browser + id: string + } +``` + +```js + +// export: 获取浏览器的cookeis信息 +let cookies = await page.control.browserContext.cookies(); +``` \ No newline at end of file