Get chrome's console log

后端 未结 8 1440
感动是毒
感动是毒 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:19

    Here is a solution to get Chrome logs using the C#, Specflow and Selenium 4.0.0-alpha05. Pay attention that the same code doesn't work with Selenium 3.141.0.

     [AfterScenario]
        public void AfterScenario(ScenarioContext context)
        {
            if (context.TestError != null)
            {         
                GetChromeLogs(context); //Chrome logs are taken only if test fails
            }
            Driver.Quit();
        }
    
        private void GetChromeLogs()
        {
            var chromeLogs = Driver.Manage().Logs.GetLog(LogType.Browser).ToList();            
        }
    

提交回复
热议问题