'Allow' Chrome Geolocation popup in WebdriverIO

Viewed 270

I want to enable geolocation(using service: dev-tools) when webdriverIO spins up the chrome browser by default. Any idea where can I make the change to achieve this? I am faking my geolocation via browser.cdp but when the browser spins up it asks me to 'Allow' the location first before the test proceeds and I don't want this manual intervention.

enter image description here

I have tried a lot of options in wdio.config file, latest one being-

browserName: 'chrome',
        'goog:chromeOptions': {
            prefs: { 'credentials_enable_service': false, 'profile': { 'password_manager_enabled': false, 'default_content_setting_values': { 'geolocation': 1 } } }
        },
services: ['devtools'],

But the above configuration is also not working.

My code in test file is as follows -

    it('TC070_Geolocations', () => {
        browser.url('https://www.where-am-i.co/')        
        browser.cdp('Emulation', 'setGeolocationOverride', {
            latitude:51.507351,
            longitude:-0.127758,
            accuracy: 1
        })
        browser.cdp('Emulation', 'setTimezoneOverride', {
            timezoneId: 'Europe/London'
        })
        browser.pause(5000)
        browser.saveScreenshot('Screenshots/a.png')

    })
0 Answers
Related