Get chrome's console log

后端 未结 8 1427
感动是毒
感动是毒 2020-11-28 09:05

I want to build an automation testing, so I have to know the errors that appear in the console of chrome.

there is an option to get the error lines that appear in th

8条回答
  •  醉酒成梦
    2020-11-28 09:08

    You can get logs this way:

    Driver().Manage().Logs.GetLog();
    

    By specifying what log you are interested in you can get the browser log, that is:

    Driver().Manage().Logs.GetLog(LogType.Browser);
    

    Also remember to setup your driver accordingly:

    ChromeOptions options = new ChromeOptions();
    options.SetLoggingPreference(LogType.Browser, LogLevel.All);
    driver = new ChromeDriver("path to driver", options);
    

提交回复
热议问题