Catching JS error's

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Catching JS error's

Post by Deepak_Singh » Tue May 13, 2014 7:26 am

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Catching JS error's

Post by odklizec » Tue May 13, 2014 7:49 am

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?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: Catching JS error's

Post by Deepak_Singh » Tue May 13, 2014 8:35 am

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();
}  

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Catching JS error's

Post by odklizec » Tue May 13, 2014 8:43 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Catching JS error's

Post by krstcs » Tue May 13, 2014 2:42 pm

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.
Shortcuts usually aren't...

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: Catching JS error's

Post by Deepak_Singh » Tue May 13, 2014 2:43 pm

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Catching JS error's

Post by odklizec » Tue May 13, 2014 2:52 pm

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?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: Catching JS error's

Post by Deepak_Singh » Thu May 15, 2014 11:30 am

Yes that was not what i was looking for.


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


Regards,
Deepak :(

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Catching JS error's

Post by odklizec » Thu May 15, 2014 12:40 pm

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? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration