How to suppress console error/warning/info messages when executing selenium python scripts using chrome canary

后端 未结 5 658
囚心锁ツ
囚心锁ツ 2020-12-09 16:21

I am running python script (complete script link below) for selenium test using Chrome Canary. The test seems to be running fine, however, there are lots of error/warning/in

相关标签:
5条回答
  • 2020-12-09 16:31

    I have just tested this one, it works for me (C#):

        ChromeOptions options = new ChromeOptions();
        options.AddArguments("--headless", "--log-level=3");
        RemoteWebDriver driver = new ChromeDriver(options);
    
    0 讨论(0)
  • 2020-12-09 16:38

    If "--log-level" doesn't work for you (as of 75.0.3770.100 it didn't for me), this should:

    options = webdriver.ChromeOptions()
    options.add_experimental_option('excludeSwitches', ['enable-logging'])
    driver = webdriver.Chrome(executable_path='<path-to-chrome>', options=options)
    

    see:

    https://bugs.chromium.org/p/chromedriver/issues/detail?id=2907#c3

    Python selenium: DevTools listening on ws://127.0.0.1

    0 讨论(0)
  • 2020-12-09 16:38

    Works for me in Python/Chrome...

    from selenium.webdriver.chrome.options import Options
    
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--log-level=3')
    
    0 讨论(0)
  • 2020-12-09 16:47

    Try options.add_argument('log-level=3').

    log-level: 
    Sets the minimum log level.
    Valid values are from 0 to 3: 
    
        INFO = 0, 
        WARNING = 1, 
        LOG_ERROR = 2, 
        LOG_FATAL = 3.
    
    default is 0.
    
    0 讨论(0)
  • 2020-12-09 16:49

    You can take help of below link.

    List of Chromium Command Line Switches

    "--log-level" sets the minimum log level. Valid values are from 0 to 3: INFO = 0, WARNING = 1, LOG_ERROR = 2, LOG_FATAL = 3.

    0 讨论(0)
提交回复
热议问题