Page 1 of 1

How to detect error icon coming from web application.

Posted: Mon Jan 28, 2013 12:31 pm
by Swapnil_d13
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

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

Posted: Tue Jan 29, 2013 5:11 pm
by Support Team
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)

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

Posted: Wed Jan 30, 2013 6:41 am
by Swapnil_d13
Please find attached ranorex snapshot.

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

Posted: Fri Feb 01, 2013 2:36 pm
by Support Team
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)

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

Posted: Thu Feb 07, 2013 7:35 am
by Swapnil_d13
It worked. :D :D

Thanks,
Swapnil

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

Posted: Thu Feb 07, 2013 5:44 pm
by Support Team
Hello,

Thanks for your feedback :-)

Regards,
Markus (T)(