繁体   English   中英

如何使用Selenium WebDriver中的Firefox功能禁用网站的地理位置权限

[英]How to disable geolocation permissions for a website using firefox capabilities in selenium webdriver

我想在Selenium Webdriver中使用Firefox功能禁用网站的地理位置许可,但是我不能这样做。

我尝试这样做...

WebDriver d = null;
cap = cap.merge(DesiredCapabilities.firefox());
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("geo.enabled", false);
cap.setCapability("geo.provider.use_corelocation", false);
cap.setCapability("geo.prompt.testing", false);
cap.setCapability("geo.prompt.testing.allow", false);

附件是相同的屏幕截图

在此处输入图片说明

我没有尝试使用您的特定参数,但对于其他参数来说,效果很好,如下所示:

FirefoxProfile profile = new FirefoxProfile();  
// Turn off updates
profile.setPreference("app.update.enabled", false);
WebDriver driver = new FirefoxDriver(profile);

使用Selenium 2.48和FF 42.0(但其他版本也应如此)。

这对我有用

caps.setCapability("locationContextEnabled", false);

暂无
暂无

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

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