I use Ranorex to perform bulk input of data into HR databases that I host, rather than as a testing application.
Quite often when entering data, dialogs are displayed depending on the conditions of the individual entry. The thing is, they aren't always displayed so I needed a way of dealing with these unexpected dialogs.
I followed the instructions on the Ranorex Blog 'Handling dialog and pop-up windows' and it seems to work for a few entries and then I get an odd error, where Ranorex cannot find the unexpected dialogs. From my understanding, the separate thread is constantly looking for the dialogs, however only closes them IF they are found. I can't understand why the error is being displayed.
This is the user code I'm using as the separate thread:
public partial class Recording1
private void Init()
Thread dialogWatcher = new Thread(ClosePopUpDialogs);
dialogWatcher.IsBackground = true;
public static void ClosePopUpDialogs()
if (repo.Unknown.SelfInfo.Exists() )
This is my "Unknown" item in the repository that is being watched for:
/form[@title!='(Empower-HR(raven::mydb_prod)|Skill|Skill - Add|admin)' and @accessiblename='Empower-HR'] - essentially watching for any window other than the ones I need to enter data into.
And this is the error message that randomly pops up:
Ranorex.ElementNotFoundException: Failed to find item 'Upload_skillsRepository.Unknown.Close'. ---> Ranorex.ElementNotFoundException: No element found for path 'titlebar/button[@accessiblename='Close']' within 30s.
at UnknownAppFolder.get_Close in c:\Users\TEMP.TMD.018\Documents\Ranorex\RanorexStudio Projects\Upload_skills\Upload_skills\Upload_skillsRepository.cs:line 3172
at Upload_skills.Recording1.ClosePopUpDialogs in c:\Users\TEMP.TMD.018\Documents\Ranorex\RanorexStudio Projects\Upload_skills\Upload_skills\Recording1.UserCode.cs:line 46
Also, I get some strange behavior from Ranorex occasionally where it seems to get stuck mid-script. I have a couple of 3500ms delays built in but apart from that each action is 200ms. The only way to recover from the 'freezes' is to stop the script.
This is my first time using user code and I'm at a loss. Any help anyone could give would be greatly appreciated! Thank you for your time.
Ask general questions here.
2 posts • Page 1 of 1
A few ideas pop up to my mind, what could cause the "Close" button not to be found. These are the most likely ones
- The dialog has no "Close" button. Rather use the Form.Close method
- Do you start the recording a few times? If yes, then with every recording a new thread will be launched searching for the dialog. If two threads happen to execute the Click on the "Close" button at the same time, the error will pop up.