How to detect error icon coming from web application.

Ask general questions here.
Swapnil_d13
Posts: 11
Joined: Mon Jan 14, 2013 8:50 pm

How to detect error icon coming from web application.

Post by Swapnil_d13 » Mon Jan 28, 2013 12:31 pm

Hi,
How can ranorex detect error icon coming from web application and stops test case. If I am running 3 test cases back to back and in second test case, error icon came in status bar for some reason. I want to stop test case and log valid error message in Report.Log(......).

Image

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to detect error icon coming from web application.

Post by Support Team » Tue Jan 29, 2013 5:11 pm

Hello,

Could you please post a 'Ranorex Snapshot' of your application when this error icon is shown?
Please take a look at section Creating Ranorex Snapshot Files in our User Guide.

Regards,
Markus (T)
.
Image

Swapnil_d13
Posts: 11
Joined: Mon Jan 14, 2013 8:50 pm

Re: How to detect error icon coming from web application.

Post by Swapnil_d13 » Wed Jan 30, 2013 6:41 am

Please find attached ranorex snapshot.
Attachments
Error_icon_snapshot.rxsnp
(274.78 KiB) Downloaded 228 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to detect error icon coming from web application.

Post by Support Team » Fri Feb 01, 2013 2:36 pm

Hello,

It is a bit tricky to implement your desired behavior.
Please follow these steps:

1) You need a bool field and a PopupWatcher in your UserCode:
private static bool abortTest = false;
private static PopupWatcher myPopupWatcher = new PopupWatcher();

private void Init()
{	
	string yourItem = "/form[@title~'^Risk\ Policy\ Manager\ -\ Win']/element[@class='Frame Tab']//listitem[@text='Done']";
	myPopupWatcher.Watch(yourItem, WarningIsShown);
	myPopupWatcher.Start();							
}
2) You need to create a method for the PopupWatcher:
public static void WarningIsShown(Ranorex.Core.RxPath myPath, Ranorex.Core.Element myElement)
{
	Report.Info("Warning is shown!");
	abortTest = true;
	myPopupWatcher.Stop();
}
3) You need to add a UserCode method in your recording (last action e.g.):
public void endTest()
{
	if (abortTest)
	{
		throw new Exception("Test was aborted because of a popup.");
	}
}
Please try out these steps.

Regards,
Markus (T)
.
Image

Swapnil_d13
Posts: 11
Joined: Mon Jan 14, 2013 8:50 pm

Re: How to detect error icon coming from web application.

Post by Swapnil_d13 » Thu Feb 07, 2013 7:35 am

It worked. :D :D

Thanks,
Swapnil

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to detect error icon coming from web application.

Post by Support Team » Thu Feb 07, 2013 5:44 pm

Hello,

Thanks for your feedback :-)

Regards,
Markus (T)(
.
Image