简体   繁体   English

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

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

I want to disable the geolocation permissions for a website using firefox capabilities in selenium webdriver, but i am not able to do so. 我想在Selenium Webdriver中使用Firefox功能禁用网站的地理位置许可,但是我不能这样做。

I tried doing this... 我尝试这样做...

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);

Attached is the screenshot of the same 附件是相同的屏幕截图

在此处输入图片说明

I haven't tried with your specific parameter but for others it works well, like this: 我没有尝试使用您的特定参数,但对于其他参数来说,效果很好,如下所示:

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

Using Selenium 2.48 and FF 42.0 (but it should do for other versions, as well. 使用Selenium 2.48和FF 42.0(但其他版本也应如此)。

这对我有用

caps.setCapability("locationContextEnabled", false);

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

相关问题 如何使用带有Java的Selenium Webdriver在Firefox中禁用不安全密码警告 - How to disable Insecure Password Warning in Firefox using Selenium Webdriver with Java Selenium:如何在Firefox中禁用webdriver =“ true”? - Selenium: How to Disable webdriver=“true” in Firefox? Selenium WebDriver,Firefox,Centos无法找到匹配的功能集 - Selenium WebDriver, Firefox, Centos, unable to find a matching set of capabilities 如何禁用Selenium Webdriver和Firefox浏览器的ProPro浏览? - How can I disable provate browsing with selenium webdriver, and firefox browser? Selenium WebDriver / Firefox | Chrome / Java如何禁用图像加载 - Selenium WebDriver/Firefox|Chrome/Java How to disable image loading 如何使用Selenium Webdriver禁用键盘快捷键? - How to disable keyboard shortcuts using Selenium webdriver? 如何使用带有Java的Selenium WebDriver将命令写入Firefox控制台? - How to write commands into the Firefox console using Selenium WebDriver with Java? 如何使用 Firefox 的 selenium Webdriver 处理 Shadow-dom 元素 - How to handle Shadow-dom elements using selenium Webdriver for Firefox 如何使用Selenium Webdriver取消在Firefox中的下载? - How can i cancel a download in firefox by using Selenium Webdriver? 如何在 Firefox 19 中使用 Selenium WebDriver 进行鼠标悬停? - How to do mouse hover using Selenium WebDriver in Firefox 19?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM