크롬드라이브 옵션

  1. ChromeDriverService driverService = ChromeDriverService.CreateDefaultService();
  2. driverService.HideCommandPromptWindow = 진짜;// 검은색 cmd 창을 닫습니다.
  3. Chrome옵션 옵션 = 새로운 크롬 옵션();
  4. // 비 새로 고침 장치
  5. //options.AddArgument(“–headless”);
  6. // GPU 가속으로 인해 ChromeOutput 최신 블랙 스크린 및 CPU가 발생할 수 있습니다.
  7. options.AddArgument(“–비활성화-gpu”);
  8. // 가장 사용자 에이전트
  9. options.AddArgument(“user-agent=Mozilla/5.0(iPhone; Mac OS X와 ​​같은 CPU iPhone OS 10_3) AppleWebKit/602.1.50(Gecko와 같은 KHTML) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1”);
  10. // 크롬 크기 줄이기
  11. options.AddArgument(“–창 크기=414,736”);
  12. // 예시 사용
  13. options.AddUserProfilePreference(“profile.default_content_setting_values.images”, 2);
  14. IWebDriver-Selenium = 새로운 ChromeDriver(드라이버 서비스, 옵션);
  15. //5S 이내에 검색 요소를 찾지 못한 경우
  16. selenium.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
  17. URL = https://www.baidu.com;
  18. selenium.Navigate().GoToUrl(url);