Mock the geolocation of the browser. Call without any arguments to reset the geolocation back to original.

Usage

                    .setGeolocation({latitude, longitude, accuracy}, [callback])
                

Example

 describe('mock geolocation', function() {
   it('sets the geolocation to Tokyo, Japan and then resets it', () => {
     browser
       .setGeolocation({
         latitude: 35.689487,
         longitude: 139.691706,
         accuracy: 100
       })  // sets the geolocation to Tokyo, Japan
       .navigateTo('https://www.gps-coordinates.net/my-location')
       .pause(3000)
       .setGeolocation()  // resets the geolocation
       .navigateTo('https://www.gps-coordinates.net/my-location')
       .pause(3000);
   });
 });

Parameters

Name Type description
coordinates
Optional
object

Latitude, longitude, and accuracy.

callback
Optional
function

Callback function to be called when the command finishes.