WebdriverIO -如何接受Chrome的位置提示?(chromedriver)

bbmckpt7  于 2023-03-06  发布在  Go
关注(0)|答案(1)|浏览(181)

我目前正在为一个网站进行自动化测试,当它以匿名模式启动时,会询问用户的位置。(类似于https://www.where-am-i.co/)。然而,虽然我设法配置了位置被拒绝,但我无法配置它在每次浏览器启动时自动接受。
在wdio.conf.js中,我在“能力”下放置了

"goog:chromeOptions": {
            args: [
                "--incognito"
            ],
            prefs: {
                'profile': {
                 'default_content_setting_values': {
                    'geolocation': 1
                  }
                }
              },
        }
}],

设置'geolocation': 1应该每次都确认位置,但它不起作用。但是,如果地理位置设置为2,它确实起作用,位置提示被拒绝。

ahy6op9u

ahy6op9u1#

尝试在您的“goog:chromeOptions”中设置此选项:

'goog:chromeOptions': {
        prefs: {
            'profile.managed_default_content_settings.popups' : 1,
            'profile.managed_default_content_settings.notifications' : 1,
        }
    },

相关问题