1.コールクロムドライバ
するSystem.setProperty( "webdriver.chrome.driver"、 "C:/プログラムファイル(x86の)/Google/Chrome/Application/chromedriver.exe");
2. chromeOptionオブジェクトを作成します。
ChromeOptions chromeOptions = 新しい ChromeOptions();
3.プロパティが設定されています
図なし3.1に配置されていません。
地図<文字列、オブジェクト>のprefs = 新しい HashMapの<文字列、オブジェクト> (); prefs.put( "profile.managed_default_content_settings.images"、2 )。 chromeOptions.setExperimentalOption( "環境設定"、環境設定)。
無料検出器が提供さ3.2(開発者モード)
リストexcludeSwitches = 新しいのArrayList <文字列> (); excludeSwitches.add( "自動化を可能にします" ); chromeOptions.setExperimentalOption( "excludeSwitches"、excludeSwitches)。
3.3 IPプロキシ設定
文字列のIP = "122.236.112.128:4267" 。
chromeOptions.addArguments( "--proxy-サーバー=のhttp://" + IP)。
3.4の設定、ブラウザのサイズ
ドライバ= webdriverを新しい新ChromeDriver(chromeOptions); // ブラウザのリサイズ driver.manage()ウィンドウ()のsetSize(.. New新しい寸法(1300、800 ;)) ((ChromeDriver)ドライバ)に.get(URLを);
3.5設定されたCookie
クッキークッキー= 新しいクッキー(「名前」、「値」); driver.manage()addCookie(クッキー)。
3.6ヘッドレスを設定します
chromeOptions.addArguments( " - ヘッドレス");