6

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

Carpetfizz
  • 8,707
  • 22
  • 85
  • 146
  • Possible duplicate of [this question](http://stackoverflow.com/questions/20907180/getting-console-log-output-from-chrome-with-selenium-python-api-bindings). – rgajrawala Jul 11 '14 at 20:29

1 Answers1

1

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.

rac2030
  • 507
  • 3
  • 10