我已经得到了解决这个在Firefox但对铬仍在工作。下面的代码应帮助并在地图上获取你的确切位置:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("default");
myprofile.setPreference("geo.prompt.testing", true);
myprofile.setPreference("geo.prompt.testing.allow", true);
myprofile.setPreference("geo.wifi.uri", "https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE,myprofile);
后,这只是通过FirefoxProfile例如在驾驶方法,就像下面(上面的代码):
driver = new FirefoxDriver(myprofile);
应没问题,写所有你想要的其他东西并执行!
它用于测试网站的功能,允许用户启用位置跟踪。 – FilmiHero