Firefox Webdriver实例'打开x2 Windows'而不只是' x1 Window'

时间:2017-01-18 17:06:39

标签: java selenium selenium-webdriver webdriver

Firefox Webdriver实例'打开x2 Windows'而不只是' x1 Window'

任何想法?

try {
    // Load the driver selected by user
    Properties p = new Properties();
    FileInputStream fi = new FileInputStream(Constant.CONFIG_PROPERTIES_DIRECTORY);
    p.load(fi);

    String browserName = p.getProperty("browser");
    switch (browserName) {
        case "firefox":
            if (null == webdriver) {
                System.setProperty("webdriver.gecko.driver",Constant.GECKO_DRIVER_DIRECTORY );
                webdriver = new FirefoxDriver(DesiredCapabilities.firefox());
                webdriver = new FirefoxDriver();
            }
            break;
        case "chrome":
            if (null == webdriver) {
                System.setProperty("webdriver.chrome.driver", Constant.CHROME_DRIVER_DIRECTORY );
                webdriver = new ChromeDriver();
            }

enter image description here

1 个答案:

答案 0 :(得分:1)

您的来电new FirefoxDriver()两次。

完全删除此行:

webdriver = new FirefoxDriver(DesiredCapabilities.firefox());