I am using selenium's RemoteWebDriver and c#. Right now I am injecting a javascript function into the head of a page that looks like this
"window.__webdriver_javascript_errors = [];
window.onerror = function(errorMsg, url, line) {
window.__webdriver_javascript_errors.push(
errorMsg + ' (found at ' + url + ', line ' + line + ')');
};";
It is injected by fiddler proxy and it stores javascript errors on the page into an array. I can then use IJavascriptExecuter to extract this method.
However, instead of this, I want to have the javascript automatically call a c# method whenever an error is found so I can log it right away. Is there a way to do this?