Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access browser logs in Selenium?

Is there a way to access logs on the browser made by the sever in Selenium? For example, if the site executed a console.log("Test."), can a Selenium test case access that log? Any help would be appreciated! (Preferably in Python).

Thanks!

~Carpetfizz

like image 644
Carpetfizz Avatar asked Aug 18 '13 09:08

Carpetfizz


1 Answers

You could inject javascript and override the log function (as reading the log is not permitted from JS). See http://tobyho.com/2012/07/27/taking-over-console-log/ for an example and there are many SO questions on this topic.

The problem with this is that it still can't get the logs which happened prior to injection.

It gets easier if you override this in the test deployment directly.

like image 94
rac2030 Avatar answered Sep 27 '22 18:09

rac2030