加载chrome用户配置
System.setProperty("webdriver.chrome.bin", "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
System.setProperty("webdriver.chrome.driver", "C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe"); //chromedriver.exe的安装路径
//设置Webdriver启动chrome为默认用户的配置信息(包括书签、扩展程序等)
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/acer/AppData/Local/Google/Chrome/User Data"); //第一步chrome://version/中的对应信息
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();//窗口最大化
加载firefox用户配置
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("default"); //default为火狐默认
WebDriever driver = new FirefoxDriver(profile);