You can execute your own JavaScript to connect to window.onerror .
You can tell your JavaScript to return your data to Selenium, but since you are asking for errors, I suggest not doing this. Depending on the error, the error may break JavaScript and may prevent it from returning.
A more reliable way would be to create a server that provides a handler on the Internet for a request from your JS.
So, your JS for execution from Selenium (before errors) may look like this:
window.onerror = function(message, file, line) { var asyncHR = new XMLHttpRequest(); var URL = "https://www.yourserver.com/errorlogger?file=" + file + "&line=" + line + "&message=" + message; asyncHR.open("GET", URL, true); asyncHR.send(); };
And from there let the server take care of registration - write to a file, DB, etc.
source share