Selenium 사용시 console output 설정

Selenium 제어 작업을 수행하면 아래와 같이 WAS 나 실제 프로그램에서 출력되는 log4j 로그와 별개로 selenium 브라우저 드라이버에서 출력하는 내용이 중간중간 나타나는 경우가 있다.

2024-01-10 19:37:45,776 [Thread-1] INFO : 디렉토리 생성 완료
2024-01-10 19:37:45,776 [Thread-1] INFO : 디렉토리 생성 true
2024-01-10 19:37:45,776 [Thread-1] INFO : 이미지 방식 저장
JavaScript warning: https://pagead2.googlesyndication.com/bg/MCFrRHZE15CKjvM6RLwmjguI7mqh03m56A7oA9GJNi8.js line 2 > eval line 72 > eval line 1 > eval line 1 > eval, line 1: WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.
console.error: ({})
JavaScript error: https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js, line 89: TagError: adsbygoogle.push() error: All 'ins' elements in the DOM with class=adsbygoogle already have ads in them.
2024-01-10 19:38:30,837 [Thread-1] INFO : 디렉토리 생성 완료
2024-01-10 19:38:30,837 [Thread-1] INFO : 디렉토리 생성 true
2024-01-10 19:38:30,837 [Thread-1] INFO : 이미지 방식 저장
JavaScript warning: https://pagead2.googlesyndication.com/bg/MCFrRHZE15CKjvM6RLwmjguI7mqh03m56A7oA9GJNi8.js line 2 > eval line 646 > eval line 1 > eval line 1 > eval, line 1: WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.
console.error: ({})
JavaScript error: https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js, line 89: TagError: adsbygoogle.push() error: All 'ins' elements in the DOM with class=adsbygoogle already have ads in them.

로그 보기에도 좋지 않고 여간 짜증나는게 아니다. 이것을 안나오게 설정하기 위해서는 아래와 같이 시스템 환경변수를 설정해주면 된다.

// Firefox / Geckodriver인 경우
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "firefox.log");
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.EnableVerboseLogging = false;
service.SuppressInitialDiagnosticInformation = true;
service.HideCommandPromptWindow = true;

ChromeOptions options = new ChromeOptions();

options.PageLoadStrategy = PageLoadStrategy.Normal;

options.AddArgument("--window-size=1920,1080");
options.AddArgument("--no-sandbox");
options.AddArgument("--headless");
options.AddArgument("--disable-gpu");
options.AddArgument("--disable-crash-reporter");
options.AddArgument("--disable-extensions");
options.AddArgument("--disable-in-process-stack-traces");
options.AddArgument("--disable-logging");
options.AddArgument("--disable-dev-shm-usage");
options.AddArgument("--log-level=3");
options.AddArgument("--output=/dev/null");

Browser = new ChromeDriver(service, options);
로그인하면 댓글을 남길 수 있습니다.
  • selenium_사용시_console_output_설정.txt
  • 마지막으로 수정됨: 2024/01/10 11:42
  • 저자 koov