Reputation: 1116
I am writing a web application that depends heavily on geolocation. I am using chimpjs (combination of cucumber, webdriverio, chai) to do my BDD. I would like to launch google chrome with geolocation allowed. I think I must do this because I can find no way to click the Allow button in chrome to allow geolocation.
I have a chimp.js config file in my cucumber directory. Here are its contents:
module.exports = {
webdriverio: {
desiredCapabilities: {
chromeOptions: {
deviceName: 'Google Nexus 5'
}
}
},
browser: 'chrome',
watch: false,
path: './features',
chai: true,
screenshotsPath: '.screenshots'
};
I know that:
What I cannot figure out is which among these need to be passed to chromeOptions, and what needs to be nested where.
I am sure I cannot be the only person who ever needed to launch chrome with webdriver and have geolocation enabled.
Upvotes: 1
Views: 1119
Reputation: 15030
You can simply configure this in chromeOptions
with profile.default_content_setting_values.geolocation
.
chromeOptions: {
deviceName: 'Google Nexus 5'
prefs: {
"profile.default_content_setting_values.geolocation": 1,
}
},
Upvotes: 2
Reputation: 2533
This question is a duplicate of this one: How do I enable geolocation support in chromedriver for Selenium?
I've translated the answer to WebdriverIO syntax:
browser.execute(function() {
window.navigator.geolocation.getCurrentPosition = function(success) {
var position = { coords : { latitude: "40.748440", longitude: "-73.984559" } };
success(position);
}
});
Upvotes: 0