【问题标题】:How to disable geolocation permissions for a website using firefox capabilities in selenium webdriver如何在 selenium webdriver 中使用 Firefox 功能禁用网站的地理位置权限
【发布时间】:2016-01-21 11:24:18
【问题描述】:

我想在 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);

附上相同的截图

【问题讨论】:

    标签: java firefox selenium-webdriver


    【解决方案1】:

    我没有尝试过你的具体参数,但对其他人来说效果很好,如下所示:

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

    使用 Selenium 2.48 和 FF 42.0(但它也应该适用于其他版本。

    【讨论】:

      【解决方案2】:

      这对我有用

      caps.setCapability("locationContextEnabled", false);
      

      【讨论】:

        猜你喜欢
        • 2016-04-16
        • 1970-01-01
        • 2016-01-03
        • 2019-01-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-22
        • 2014-10-07
        相关资源
        最近更新 更多