Before webdriver starts chrome and firefox, read personal configuration files

Reprinted from: http://www.vingo.cn/vingo/?p=1172

When webdriver opens chrome and firefox browsers, the default is to create a new user, and each time it is opened, it is a brand new browser. For browsers that need to use npapi plug-ins, there will be troubles. By loading the personal configuration file, when opening the browser for the first time, manually set whether to load the npapi plug-in. Subsequent runs will directly use the previous configuration information without repeated prompts.

chrome:
ChromeOptions options = new ChromeOptions();
options.addArguments(“–user-data-dir=C:/Users/xxx/AppData/Local/Google/Chrome/User Data/Default”);
WebDriver driver = new ChromeDriver(options);

firefox:
FirefoxProfile fp = new FirefoxProfile();
ProfilesIni allProfiles = new ProfilesIni();
fp = allProfiles.getProfile(“default”);
WebDriver driver = new FirefoxDriver(fp);

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326941771&siteId=291194637