we don't have it as a built-in feature and it would make a great Feature Request so I'm going to log it.
Anyway I managed to come up with a way to do though it has some drawbacks.
Here's how you can do that:
- this works for IE7 and 8.
You can find similar articles on how to change the same setting for the other browsers.
There's is a way out of it - you set a relatively short timeout for your NavigateTo step and you also set it "ContinueOnFailure". Now, when you get the pop-up, WebUI TS will stop trying to load the page at some point and will declare the step to be a failure. If there's no pop-up then execution will continue normally.
Immediately after this step you have to put 5 more steps:
1) Connect to Dialog
2) Click on Copy Error To Clipboard
3) Click Cancel
4) Disconnect from Dialog
5) Paste the content of the Clipboard to the Log
For the fifth step you can reuse my code:
String idat =
Exception threadEx =
Thread staThread =
idat = System.Windows.Clipboard.GetText();
threadEx = ex;
You will have to add PresentationCore.dll to your references and also add a
in order to get it to compile.
So you take those 5 steps and put them after the navigateTo
step that takes you the page that you want to test for JS errors and you're set to go.
It would be a great idea to have this whole thing as a separate test and just add it with "Test as Step" when you need it. Keep in mind that it will ALWAYS fail:
- no JS errors --> Dialog Handling Fails;
-has JS errors --> the timeout fails;
I've attached a completely-working example test. You can even reuse it without changing anything at all except the URL to which it navigates (and tests). And you have to add a reference to PresentationCore.dll before it will work.
I realize you might not succeed in getting all of this to work on the first try - don't give up. I managed to get it working without too much trouble and so can you - we can help if you get stuck.
Please let us know how it goes!
the Telerik team