javascript - how set geolocation to block in chrome using puppeteer
问题描述
I am looking for a way to respond block when being asked about sharing my location
I got to the point that I do
const context = browser.defaultBrowserContext();
context.clearPermissionOverrides();
I when I do this and login to my app I get the share location pop-up. After that I am able to set my location by doing
context.overridePermissions(global.URL, ['geolocation']);
await page.setGeolocation({
latitude: 39.103957,
longitude: -76.834938
});
What I actually looking to do is respond 'block' to the share location pop-up. Below is how my test would eventually look
it("shows error page", async () => {
await page.setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X)
AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1")
const context = browser.defaultBrowserContext();
context.clearPermissionOverrides();
//somehow respond blocked
await common.login(page, global.USER4,global.PASSWORD4)
expect(await landingPage.getText()).toMatch("error text")
})
解决方案
推荐阅读
- hadoop - 更改主机名后的 java.net.ConnectException
- r - 使用 R 中的查找表基于另一个 df 创建新列
- python - 当索引是日期时间时,如何将两个 pandas 日期时间序列 DataFrame 相减?
- c++ - 非空函数潜在缺乏回报
- python - 处理多个用户 URL 输入,然后需要单独拆分和处理
- javascript - Angular - 选择错误 - NgFor 仅支持绑定到可迭代对象,例如数组
- javascript - 如果定义为函数参数,匿名函数何时执行?
- sql - 使用 kingswaysoft 优化插入到 crm 的记录数
- mysql - 与同一张表中的father_id和mother_id的雄辩关系
- arrays - Excel-VBA - 在数据字段数组中插入新的第一列,无需循环或 API 调用