Currently, I am utilizing selenium's RemoteWebDriver along with c#. At the moment, I am inserting a javascript function into the head of a page that has the following structure:
"window.__webdriver_javascript_errors = [];
window.onerror = function(errorMsg, url, line) {
window.__webdriver_javascript_errors.push(
errorMsg + ' (found at ' + url + ', line ' + line + ')');
};";
This script is inserted using the fiddler proxy and it captures any javascript errors on the page, storing them in an array. Later, I rely on IJavascriptExecuter to extract this data.
However, my goal now is to have the javascript function automatically trigger a c# method whenever it encounters an error, allowing me to log it immediately. Is this possible?