/// <inheritdoc cref="IBrowserContextDelegate.SetGeolocationAsync(GeolocationOption)"/>
        public async Task SetGeolocationAsync(GeolocationOption geolocation)
        {
            var request = new EmulationSetGeolocationOverrideRequest();

            if (geolocation != null)
            {
                request.Accuracy  = geolocation.Accuracy;
                request.Latitude  = geolocation.Latitude;
                request.Longitude = geolocation.Longitude;
            }

            foreach (Page page in await BrowserContext.GetPagesAsync().ConfigureAwait(false))
            {
                await((ChromiumPage)page.Delegate).Client.SendAsync(request).ConfigureAwait(false);
            }
        }
        public async Task ShouldNotModifyPassedDefaultOptionsObject()
        {
            var geolocation = new GeolocationOption {
                Latitude = 10, Longitude = 10
            };
            BrowserContextOptions options = new BrowserContextOptions {
                Geolocation = geolocation
            };
            var context = await NewContextAsync(options);

            await Page.GoToAsync(TestConstants.EmptyPage);

            await Context.SetGeolocationAsync(new GeolocationOption
            {
                Longitude = 20,
                Latitude  = 20
            });

            Assert.Equal(options.Geolocation, geolocation);
        }
 /// <inheritdoc cref="IBrowserContextDelegate.SetGeolocationAsync(GeolocationOption)"/>
 public Task SetGeolocationAsync(GeolocationOption geolocation)
 {
     throw new System.NotImplementedException();
 }
示例#4
0
 /// <inheritdoc cref="IBrowserContextDelegate.SetGeolocationAsync(GeolocationOption)"/>
 public Task SetGeolocationAsync(GeolocationOption geolocation)
 => throw new NotSupportedException("Geolocation emulation is not supported in Firefox");
 /// <inheritdoc cref="IBrowserContext.SetGeolocationAsync(GeolocationOption)"/>
 public Task SetGeolocationAsync(GeolocationOption geolocation)
 => _delegate.SetGeolocationAsync(geolocation);