public static FirefoxDriver FFSetting() { System.setProperty("webdriver.firefox.bin", "D:\Program Files (x86)\Mozilla Firefox\firefox.exe"); return new FirefoxDriver(); } public static InternetExplorerDriver IESetting() { System.setProperty("webdriver.ie.driver", "D:\selenium\IEDriverServer.exe"); // 设置系统环境变量,key-value DesiredCapabilities ieCapabilities = DesiredCapabilities .internetExplorer(); ieCapabilities .setCapability( InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); return new InternetExplorerDriver(ieCapabilities); // 实例化一个浏览器对象 }