| 15 | * "permanent allow all" button (type=4, allow=true). |
| 16 | */ |
| 17 | export function autoApprovePermissions(context: BrowserContext): void { |
| 18 | context.on("page", async (page) => { |
| 19 | const url = page.url(); |
| 20 | if (!url.includes("confirm.html")) return; |
| 21 | |
| 22 | try { |
| 23 | await page.waitForLoadState("domcontentloaded"); |
| 24 | const successButtons = page.locator("button.arco-btn-status-success"); |
| 25 | await successButtons.first().waitFor({ timeout: 5_000 }); |
| 26 | const count = await successButtons.count(); |
| 27 | if (count >= 3) { |
| 28 | await successButtons.nth(2).click(); |
| 29 | } else { |
| 30 | await successButtons.last().click(); |
| 31 | } |
| 32 | console.log("[autoApprove] Permission approved on confirm page"); |
| 33 | } catch (e) { |
| 34 | console.log("[autoApprove] Failed to approve:", e); |
| 35 | } |
| 36 | }); |
| 37 | } |
| 38 | |
| 39 | /** Run a test script from example/tests/ on the target page and collect console results */ |
| 40 | export async function runTestScript( |