我已經得到了解決這個在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