popup watcher not working correctly

Ask general questions here.
User avatar
subodh4u7
Posts: 71
Joined: Tue Jan 06, 2015 8:26 am

popup watcher not working correctly

Post by subodh4u7 » Thu Oct 01, 2015 11:37 am

Hi Ranorex Guru,

I am using below code for handling the pop up.
I have application which throws exception while running the exception as dialog box and want to click on OK button to close the exception dialog and proceed. Sometimes the below code is able to handle the exception but most of the times its not to able to handle. Can anyone please help.

Code: Select all

[b]class Program[/b]
    {
    
        public static int Main(string[] args)
        {            try
            {
            	UnexpectedPopups.Instance.Start();
            	UnexpectedPopups.Instance.Watch();
                error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
            }
            catch (Exception e)
            {
                Report.Error("Unexpected exception occurred: " + e.ToString());
                error = -1;
            }
            finally
			{

				UnexpectedPopups.Instance.Stop();
			}

	}
     }

-----------------------------------
[b]public class UnexpectedPopups: Ranorex.PopupWatcher[/b]
	{
		
		private static volatile UnexpectedPopups myInstance;
		private UnexpectedPopups()
		{
			
		}
		/// <summary>
		/// Singleton instance of the class
		/// </summary>
		public static UnexpectedPopups Instance
		{
			get
			{
				if(myInstance==null)
				{
					lock(mySyncLock )
					{
						if(myInstance ==null)
						{
							myInstance = new UnexpectedPopups ();
						}
					}
				}
				return myInstance ;
			}
		}
		/// <summary>
		/// Initiates the PopUp Watcher
		/// </summary>
		public new void Start()
		{
			base.Start ();
		}

		/// <summary>
		/// Watches for the PopUp and invokes the callback configured.
		/// </summary>
		public void Watch()
		{

			base.Watch(RepoScanConsole.Instance.PopUp_SystemFailureDialog.ButtonOkInfo, ClickButtonOnDialog);
			
		}
		
		/// <summary>
		/// Handles Dialog (PopUp) by clicking on the Button on the Dialog, based on Button's RepoItemInfo and Element object.
		/// </summary>

		public  void [b]ClickButtonOnDialog[/b](Ranorex.Core.Repository.RepoItemInfo info, Ranorex.Core.Element myElement)
		{
			Ranorex.Report.Failure ("Unexpected pop up appeared. Please check screenshot.");
			Ranorex.Report.Screenshot ();
			myElement.As<Ranorex.Button>().Click();
			//RepoScanConsole.Instance.PopUp_SystemFailureDialog.ButtonOk.Click();
		}
		

	
	}
Regards,
Subodh

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

Re: popup watcher not working correctly

Post by odklizec » Thu Oct 01, 2015 12:03 pm

Hi,

It's hard to say what's wrong without seeing the app or at least the snapshot and xpath of the dialog box in question. Could you please provide the snapshot and xpath?
Are you sure the xpath is the same with every exception dialog appearance? This is the most probable reason why the popup watcher sometimes works and sometimes don't.
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

User avatar
subodh4u7
Posts: 71
Joined: Tue Jan 06, 2015 8:26 am

Re: popup watcher not working correctly

Post by subodh4u7 » Mon Oct 05, 2015 10:24 am

I observed the problem why this is not able to handle the popup.

The problem is during run time, ranorex is not able to identify the popup, but when i close the ranorex and reopen the repository, its able to identify the same popup.

So question is how can we handle such scenario during the run time.
Regards,
Subodh

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

Re: popup watcher not working correctly

Post by odklizec » Mon Oct 05, 2015 12:05 pm

Hi,

Once again, it's very hard to tell what's wrong without seeing the snapshot and problematic xpath.

Please create a snapshot showing the application under test together with popup dialog. My guess is that the xpath used in popup watcher is not unique enough or changes with each popup appearance. Please post the snapshot and we may soon see what's the reason of your problems ;)
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

User avatar
subodh4u7
Posts: 71
Joined: Tue Jan 06, 2015 8:26 am

Re: popup watcher not working correctly

Post by subodh4u7 » Tue Oct 06, 2015 11:34 am

Thanks Guru.

Since I can not share my app and other snapshot due to company policy, here i m elaborating the rxPath as below:

I get 2 rxPath and dont know why it keep on changing:
1.
A) Popup dialog
/form[@title='System failure' and @processname='H.Infrastructure.AppFrame.Container' and @class='HwndWrapper[H.Infrastructure.AppFrame.Container.exe;STA Thread for ExceptionWindow;3907c443-8f5b-4f64-8258-48d58aed8896]']

B) Ok button on popup dialog
/form[@title='System failure' and @processname='H.Infrastructure.AppFrame.Container' and @class='HwndWrapper[H.Infrastructure.AppFrame.Container.exe;STA Thread for ExceptionWindow;3907c443-8f5b-4f64-8258-48d58aed8896]']/button[@accessiblename='OK' and @accessiblerole='PushButton' and @text='OK']

2.
A) Popup dialog
/form[@automationid='Window' and @name='System failure' and @classname='Window']

B) Ok button on popup dialog
/form[@automationid='Window' and @name='System failure' and @classname='Window']/button[@automationid='OkButton' and @name='OK' and @classname='Button']

in my repositoy i have added like this:
A) Popup dialog
/form[@title='System failure' or @name='System failure']

B) Ok Button on popup dialog
/form[@title='System failure' or @name='System failure']/button[@name='OK' or @text='OK']


Now, Can anyone please help why I am not able to close this.
You do not have the required permissions to view the files attached to this post.
Regards,
Subodh

User avatar
subodh4u7
Posts: 71
Joined: Tue Jan 06, 2015 8:26 am

Re: popup watcher not working correctly

Post by subodh4u7 » Thu Oct 08, 2015 5:24 am

Hi All,

I think i have found the issue why popup watcher is not working.

i have code module
{
repo.ButtonExam.Click();
repo.FrameTaskflowControl.ContainerTaskList.WaitForExists( 180 );
}

After clicking on the ButtonExam, exception dialog appears and control is waiting for ContainerTaskList to exist. Here popup watcher is not able to handle the exception dialog.

tested this way and worked fine:
{
repo.ButtonExam.Click();
//repo.FrameTaskflowControl.ContainerTaskList.WaitForExists( 180 );
deplay.seconds(50);
}

but once delay is over and control moves to next code module in the test suite , then its not able to handle the pop up which is appearing. its able to handle the popup whichever appears within the delay of 50sec.

i tried to create new thread and handle the popupwatcher but still didnt work
Thread dwatcher = new Thread(ClosePopUpDialog);
dwatcher.IsBackground=true;
dwatcher.SetApartmentState(ApartmentState.STA);
dwatcher.Start();

Can anyone now help me once the control waits for some other page to exist and pop up appears in between then why popup watcher doesn't work. also why control is ranorex code module function then also once pop up appears then why control doesnt shift to popupwatcher and switch back after handling.
Regards,
Subodh

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: popup watcher not working correctly

Post by Support Team » Mon Oct 12, 2015 10:22 am

Hello subodh4u7,

Please try to create a new Ranorex Code Module, within this module please use the following code in order to create a new pop-up watcher: http://www.ranorex.com/support/user-gui ... html#c4678
Afterwards, place the created code module at the very beginning of your test suite.

Please let me know if this helps.

Regards,
Robert

User avatar
subodh4u7
Posts: 71
Joined: Tue Jan 06, 2015 8:26 am

Re: popup watcher not working correctly

Post by subodh4u7 » Thu Oct 15, 2015 9:43 am

Hi Robert,

Thanks for the advise, however this also doesn't work as it should work.

What I understood that Popupwatcher running on separate thread and ranorex test suite runs on separate thread. Ranorex wants to access repository( in case waitForExist(), ..) function and when popup appears it then popupwatcher wants to access the repository, but since its been locked by ranorex thread and doesnt release hence popupwatcher is not able to handle the popups. Once ranorex threads comes out of the fucntion then control goes to popupwatcher and hence it handles the popup. But it takes so much time to handle( 10mins or so..) which is too much time.

I am not sure why such blockage happening.
Regards,
Subodh

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: popup watcher not working correctly

Post by Support Team » Fri Oct 16, 2015 1:32 pm

Hi Subodh,

Maybe it would help if you could provide further information about your scenario. Are there a few steps which have to be done by the popup-watcher?

Thanks,
Robert

User avatar
subodh4u7
Posts: 71
Joined: Tue Jan 06, 2015 8:26 am

Re: popup watcher not working correctly

Post by subodh4u7 » Mon Oct 19, 2015 5:01 am

Hi Robert,
The scenario is as follows:
1. Click on Exam button and wait for next screen to be visible(next screen appears in 20-30 sec).
2. In between, we observe some pop up dialog which is thrown by application
3. We want to close this pop up as soon as it appears, unless we don't close this pop up , next screen doesn't appear.
4. We do not want to terminate the test case execution because we want to run the whole workflow and observe any further popups or system exception
5. Again click on some other button to move to other screen and observe the exception pop up and handle this.

Hope, i have explained the scenario. Please let me know if you require further information.
Regards,
Subodh

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: popup watcher not working correctly

Post by Support Team » Wed Oct 21, 2015 11:25 am

Hi Subodh,

Thank you for the additional information. If it is OK for you I’d like to analyze this behavior directly on your machine.
Therefore, may I ask you to contact me by email? ([email protected])

Regards,
Markus (S)