Page 1 of 1

Dialog Box Loop Problem

Posted: Tue Mar 28, 2017 4:33 pm
by mcs
Hi,

My AUT has a dialog box which appears at a couple of different times for different reasons. The form is the same but the title bar is different. I do not want to use the popup watcher since I'd like to know when these dialogs are encountered and handled. I have written a small user code method which catches the condition but, due to my inadequate C# coding skills, it continues to have issues:
In my AUT it is not uncommon for this dialog box to appear and, after I click the button to dismiss it, appear again for the same reason as its first appearance; this is not unexpected but, also, not always the case.
The way that my method is working right now is that the first dialog is caught, dealt with, the second dialog if it exists is caught and dealt with... but then it continues to look for the dialog until my test case eventually fails since it cannot be found.
Could someone please tell me what I'm doing wrong; I'm sure that it's probably something simple that I'm missing.
Thanks.

Code: Select all

[language=csharp] 
public void Wait_For_Popup()
		{
			Report.Log(ReportLevel.Info, "Wait", "Waiting for item 'GenericDialog' to be visible.");
			

			while (repo.GenericDialog.Self.Visible == true)
			{
				
				switch (repo.Generic.Self.Title.ToString())
				{
					case "DialogOne":
						repo.DialogOne.ButtonUniqueToDialogOne.Click();
						Report.Info("Clicked Dialog One Button");
						break;
						
					case "DialogTwo":
						repo.DialogTwo.ButtonUniqueToDialogTwo.Click();
						Report.Info("Clicked Dialog Two Buggon");
						break;
						
					default:
						break;
				}
				
			}
			
		}
[/language]

Re: Dialog Box Loop Problem

Posted: Wed Mar 29, 2017 8:57 am
by Stub
I use RepoItemInfo.Exists(Duration) when I want to check to see if a dialog that may appear has indeed shown up. That way the existance test times out after a very short period. I don't use the SearchTimeout parameter on repository items, I just add a short delay. I deal with the dialog if it appears, otherwise I just move on.

I've also used this in a loop when dealing with multiple things.

Re: Dialog Box Loop Problem

Posted: Wed Mar 29, 2017 2:45 pm
by mcs
Thank you, Stub; this was exactly the advice that I was looking for and needed. I've adjusted my method per your suggestion and it works great now! Thanks again. :D