简体   繁体   中英

Firefox Webdriver Instance 'Opens x2 Windows' instead of only 'x1 Window'

Firefox Webdriver Instance 'Opens x2 Windows' instead of only 'x1 Window'

Any Ideas?

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

在此处输入图片说明

Your calling new FirefoxDriver() twice.

Remove this line completely:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM