node.js - 剧作家自动化无法绕过位置弹出窗口

标签 node.js typescript browser-automation webautomation playwright

我正在尝试使用 Playwright ( https://github.com/microsoft/playwright ),当我尝试测试库时遇到了位置弹出窗口。有没有办法绕过此弹出窗口或至少单击“阻止”或“允许”?我试过使用 Page.on("popup") 事件,但它并没有像我期望的那样工作。

popup

最佳答案

您必须使用 grantPermissions 函数来授予站点的地理定位。

await context.grantPermissions(['geolocation'], { origin: 'https://www.bestbuy.com' });

关于node.js - 剧作家自动化无法绕过位置弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65285831/

相关文章:

javascript - 使用nodejs异步回调处理循环

node.js - npm 将所有模块安装在/usr/local/lib/node_modules/

javascript - 如何确保扩展类必须在 TypeScript 中设置属性值?

html - 类型 'select' 上不存在属性 '{}'

c# - 如何通过 CSharp 以编程方式设置输入元素的值?

javascript - 在 nw.js 中使用 Liquidfun.js

javascript - 带有 typescript require 和 .d.ts 文件的 Node.js

javascript - 禁止开发者禁用任何 TSLint 规则

selenium-webdriver - Protractor/ Jasmine 测试抛出 “UnknownError: unknown error: Maximum call stack size exceeded”

javascript - 在 testcafe 中对偏离“.1”的数字执行断言的最佳方法是什么