结合Chrome选项和功能?

时间:2017-03-22 09:51:58

标签: selenium selenium-webdriver webdriver

结合Chrome选项和功能?

我在下面尝试了以下内容,但它似乎不起作用:

System.setProperty("webdriver.chrome.driver", Base_Page.getConstant(Constant.CHROME_DRIVER_DIRECTORY));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
capabilities.setCapability("chrome.binary", "<Path to binary>");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
webdriver = new ChromeDriver(capabilities);

2 个答案:

答案 0 :(得分:0)

更新到最新版本的ChromeDriver 2.28修复了我的问题

答案 1 :(得分:0)

我认为选项的组合没有意义,因为:

    if chrome_options is None:
        # desired_capabilities stays as passed in
        if desired_capabilities is None:
            desired_capabilities = self.create_options().to_capabilities()
    else:
        if desired_capabilities is None:
            desired_capabilities = chrome_options.to_capabilities()
        else:
            desired_capabilities.update(chrome_options.to_capabilities())

此行为在init。

的方法中定义