How to capture browser javascript console log ?

80 views
Skip to first unread message

vinod kumar

unread,
Jul 6, 2015, 2:35:21 PM7/6/15
to seleniu...@googlegroups.com
Hi All
Any idea how to capture browser javascript console logs like error, info ...??
I tried with LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER); but no success....

Eldho Mathulla

unread,
Jul 8, 2015, 1:44:47 PM7/8/15
to seleniu...@googlegroups.com
Hi,
If you want console logs, what you can do is override the console object functions as required by storing the arguments to a javascript object which you can retrieve later. Following is an example, which overrides console.log function and stores it in a javascript variable logs which is an array.
var logs= [
];
(function () {
  var originallog= console.log;
  console.log = function () {
    logs.push(arguments);
    originallog.apply(this, arguments);
  }
}) ();


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/397ee2e1-03d0-4af2-9840-e8567d29f0cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
                ~L2~
Reply all
Reply to author
Forward
0 new messages