Page 1 of 1

Catching JS error's

Posted: Tue May 13, 2014 7:26 am
by Deepak_Singh
Hi All,

I have a Web based Application, On which when I navigate through different Pages give's JS Error. On the Left Bottom Side (if you know).
Now my scenario is I Want to catch and perform certain steps when I get those error's anytime(Ex: Copy the details of the error in a .txt file).
But the JS' error is random and comes at any random page.

Any solution's/Advice which concept/Idea can be used here? :?:

Please Help!!!

Regards,
Deepak :D

Re: Catching JS error's

Posted: Tue May 13, 2014 7:49 am
by odklizec
Hi,

I think the best way would be to use "Handling unexpected Dialogs" code, as shown here:
http://www.ranorex.com/support/user-gui ... html#c4678

Don't be fooled by "handling unexpected dialogs" description. The code can wait and process any GUI element. Basically, if correctly implemented, the code runs in a separated thread during the execution of your test and waits for the appearance of given GUI element. If the element appears, the code jumps to a pointed method, where you can process the error according your needs (e.g. save the error to report or text file). Hope this helps?

Re: Catching JS error's

Posted: Tue May 13, 2014 8:35 am
by Deepak_Singh
So will it work if the JS error comes multiple times?
ANd why the Close button is clicked 2 times?

Code: Select all

public static void CloseUpdateCheckDialog(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)   
{   
myElement.As<Ranorex.Button>().Click();
}   
  
public static void CloseUpdateCheckDialog(Ranorex.Core.RxPath myPath, Ranorex.Core.Element myElement)   
{   
myElement.As<Ranorex.Button>().Click();
}  

Re: Catching JS error's

Posted: Tue May 13, 2014 8:43 am
by odklizec
Yes, it will work each time the GUI element in question appears. As for why the close button in below example is clicked twice, it's just an example! First one is an example of using repository item, second one uses rxpath.

Re: Catching JS error's

Posted: Tue May 13, 2014 2:42 pm
by krstcs
The button is not clicked twice.

The example shows 2 different methods that both can click the button. Each method would be called in a slightly different way.

I would highly recommend that you read up on Object Oriented Programming and .NET (especially C#) as they will both be very important in your use of Ranorex. You are developing software, so you need to learn about the environment you will be developing in.

Re: Catching JS error's

Posted: Tue May 13, 2014 2:43 pm
by Deepak_Singh
Hi,

But the Problem is this JS error comes as a element only in IE and not in Chrome and Firefox.

For them we have to go to Developer Option's and check it.

So what are your comments on this?

Regards,
Deepak

Re: Catching JS error's

Posted: Tue May 13, 2014 2:52 pm
by odklizec
I'm afraid, I don't have any experience with this. But maybe this page could help you:
http://codex.wordpress.org/Using_Your_B ... ipt_Errors
As it looks, there is no simple way to create one check for all browsers?

Re: Catching JS error's

Posted: Thu May 15, 2014 11:30 am
by Deepak_Singh
Yes that was not what i was looking for.


Can anyone else solve the Issue???? :?:


Regards,
Deepak :(

Re: Catching JS error's

Posted: Thu May 15, 2014 12:40 pm
by odklizec
I'm afraid, you won't find any easier solution of your problem. Error reporting is different in each browser. So if you really need to check and process these errors in each browser, you will have to implement browser-specific solution for each single browser. I'm almost 100% sure there is no shortcut this time ;)

Actually, there could be a "shortcut", which may help you with your problem, but it would require to add some code to your HTML page. See this tutorial (and its three previous chapters):
http://www.javascriptkit.com/javatutors/error4.shtml

The question is, if your web developers/project leader will be willing to adapt the pages to make them better testable? ;)