【发布时间】:2020-12-13 10:31:20
【问题描述】:
我正在编写测试用例以使用 Selenium webdriver 验证地图。当我尝试使用 url 打开地图时,会弹出位置警报。
我想在加载地图时默认允许地图访问当前位置而没有位置警报。
我曾尝试在 ChromeOptions 中使用配置文件,但它不能满足我的要求。
Map<String, Object> prefs = new HashMap<String, Object>();
Map<String, Object> profile = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.geolocation", 1); // 1:allow 2:block
options.setExperimentalOption("prefs", prefs);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
webDriver = new ChromeDriver(capabilities);
任何帮助将不胜感激。
【问题讨论】:
-
当然不是,我不想填充弹窗,网站需要使用当前的地理位置。
标签: java selenium geolocation selenium-chromedriver