简体   繁体   English

我如何在 selenium fireFox Python 上更改我在同一个国家/地区的位置?

[英]How i can change my location in same country on selenium fireFox Python?

I want to change my location inside country using firefox selenium, It's posible ?我想使用 firefox selenium 更改我在国内的位置,这可能吗? I search many on internet i didn't find any thing regard to this problem, just i undrestand using proxy but proxy change on diffrent country not diffrent location inside countery.我在互联网上搜索了很多我没有找到任何关于这个问题的东西,只是我不理解使用代理,但不同国家的代理更改而不是柜台内的不同位置。

I encountered a similar problem while writing a functional test with Selenium.我在使用 Selenium 编写功能测试时遇到了类似的问题。 Here is the solution.这是解决方案。

from selenium import webdriver

# geolocation supported, allowed and location mocked
ffOptions= webdriver.FirefoxOptions()
ffOptions.set_preference('geo.prompt.testing', True)
ffOptions.set_preference('geo.prompt.testing.allow', True)
ffOptions.set_preference('geo.provider.network.url','data:application/json,{"location": {"lat": 51.47, "lng": 0.0}, "accuracy": 100.0}')
browser = webdriver.Firefox(options=ffOptions)
webdriver.get('https://www.where-am-i.net/')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM