selenium中啓動chrome瀏覽器時加載配置文件

      啓動chrome瀏覽器時加載配置文件,chrome瀏覽器查看配置文件的方式:

https://blog.csdn.net/qq_24394093/article/details/82150395

import java.io.File;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

/*
 * chrome啓動時,同時加載配置文件
 */

public class KeywordBrowserChromeConfigurationFile {

	public static void main(String[] args) {
	    ChromeOptions options = new ChromeOptions();
		
		//添加配置配置文件
	    options.addArguments("--user-data-dir=C:\\Users\\11120127\\AppData\\Local\\Google\\Chrome\\User Data");
	    
	    System.setProperty("webdriver.chrome.driver", "D:\\chromedriver\\chromedriver.exe");
	    WebDriver driver = new ChromeDriver(options);
	    driver.get("http://www.baidu.com");
	}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章