Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a browser-agnostic way to detect client-side script errors with Watin?

We're using WatiN to test our web portals. During the course of an E2E test, we'll occasionally see client-side script errors on the IE status bar. I'd like to chain a handler onto the script error event and record the error for later analysis and bug filing.

Problem is, I don't know that there's a global script error event or how to chain into it. And if there's not a browser-agnostic way to accomplish this, I can create MyIE and MyFF subclasses but then this becomes two browser-specific questions.

In essence, I'm thinking of something like this entirely made-up call:

browser.ScriptEngine.SetCustomErrorHandler(LogScriptingError);

... where LogScriptErrors is my code that does the obvious.

Many of our client-side scripting errors don't necessarily prevent the test from continuing (a pretty UI element didn't animate, for example, but the underlying form is still submittable), so I'd like to log the error and forge ahead in most cases.

like image 757
Michael Avatar asked Feb 16 '10 03:02

Michael


People also ask

How do you handle client-side errors?

You can handle errors in a client-side human service by using a stand-alone error event handler or you can catch errors at a particular step by attaching a boundary error event to an individual service. To throw specific errors and end the processing of the service at a specified step, you can use error end events.

What is a client-side error?

Client-side issues are commonly caused by JavaScript errors. JavaScript errors can be a script or policy that prevents a form from loading correctly, a syntax error within a client-based script, or a reference to a non-existent element. To debug client-side errors, a web development toolbar is required.

What causes script errors?

What are Script errors? Script errors occur when a client-side script that violates the same-origin policy of the user's browser by making an invalid cross-origin HTTP request.


1 Answers

You probably looking for this:

window.onerror=function(message, url, line){logError();};

You can add this code to your pages to handle errors in logError(). but this may not work in all browser(works in IE), check this for browser compatibility:

http://www.quirksmode.org/dom/events/error.html

Or you may try this commercial product:

exceptionhub.com/

like image 178
Ehsan Avatar answered Nov 07 '22 05:11

Ehsan