Dialog Box Loop Problem

Class library usage, coding and language questions.
mcs
Posts: 35
Joined: Mon Aug 11, 2014 5:00 pm
Location: Portsmouth, NH

Dialog Box Loop Problem

Post by mcs » Tue Mar 28, 2017 4:33 pm

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]

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Dialog Box Loop Problem

Post by Stub » Wed Mar 29, 2017 8:57 am

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.

mcs
Posts: 35
Joined: Mon Aug 11, 2014 5:00 pm
Location: Portsmouth, NH

Re: Dialog Box Loop Problem

Post by mcs » Wed Mar 29, 2017 2:45 pm

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