我正在编写一个严重依赖地理定位的web应用程序。我正在用黑猩猩(黄瓜,网络驱动,海)来做我的BDD。我想推出谷歌铬地理定位允许。我认为我必须这样做,因为我找不到方法来单击铬中的允许按钮来允许地理定位。
我的黄瓜目录中有一个chimp.js配置文件。以下是它的内容:
module.exports = {
webdriverio: {
desiredCapabilities: {
chromeOptions: {
deviceName: 'Google Nexus 5'
}
}
},
browser: 'chrome',
watch: false,
path: './features',
chai: true,
screenshotsPath: '.screenshots'
};我知道:
我不知道的是,其中哪些需要传递给chromeOptions,哪些需要嵌套在哪里。
我相信我不可能是唯一一个需要使用webdriver启动chrome并启用地理定位功能的人。
发布于 2017-12-05 12:53:34
您可以简单地在chromeOptions中用profile.default_content_setting_values.geolocation配置它。
chromeOptions: {
deviceName: 'Google Nexus 5'
prefs: {
"profile.default_content_setting_values.geolocation": 1,
}
},发布于 2016-05-24 14:10:56
这个问题是这个问题的重复:How do I enable geolocation support in chromedriver for Selenium?
我已经将答案翻译为WebdriverIO语法:
browser.execute(function() {
window.navigator.geolocation.getCurrentPosition = function(success) {
var position = { coords : { latitude: "40.748440", longitude: "-73.984559" } };
success(position);
}
});https://stackoverflow.com/questions/37401087
复制相似问题