ブラウザのジオロケーションをモックします。引数なしで呼び出すと、ジオロケーションが元の状態にリセットされます。

使用方法

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

 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);
   });
 });

パラメータ

名前 説明
coordinates
オプション
オブジェクト

緯度、経度、精度。

callback
オプション
関数

コマンドが完了したときに呼び出されるコールバック関数。