使用selenium webdriver自動化網站時,我需要允許地理位置權限向前移動。我無法使用firefox配置文件的功能。如何在使用selenium webdriver的Firefox配置文件中爲網站啓用地理位置權限
Image of the geo-location pop up
像這樣的事情
public static String fileName = "/Users/Arjit/Documents/geoLocation.json";
WebDriver driver;
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("geo.enabled", true);
profile.setPreference("geo.provider.use_corelocation", true);
profile.setPreference("geo.wifi.uri",newFile(fileName).toURI().toString());
driver = new FirefoxDriver(profile);
driver.get("http://www.zoomcar.com");
而且geoLocation.json具有
{
"status": "OK",
"accuracy": 10.0,
"location": {
"lat": 12.9525060,
"lng": 77.6991510
}
}
向我們展示如何嘗試使用'capabilities'和'FirefoxProfile' – Andersson