调料室:-

https://saucelabs.com/

我使用以下工具在酱料实验室上创建firefox驱动程序:
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        capabilities.setCapability("version", "5");
        capabilities.setCapability("platform", Platform.XP);
        // Create the connection to Sauce Labs to run the tests
        this.driver = new RemoteWebDriver(
                new URL("http://YOUR_USERNAME:[email protected]:80/wd/hub"),
                capabilities);
    }

我想使用使用firefox驱动程序的移动用户代理。我该怎么做。

最佳答案

您是否尝试过创建新的配置文件并在配置文件上设置用户代理字符串?

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override", "UA-STRING");

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);

关于java - 如何在saucelabs的firefox浏览器中覆盖useragent,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28110475/

10-11 15:50