How to deal with a pop-up window

Class library usage, coding and language questions.
Posts: 1
Joined: Mon Oct 07, 2013 11:52 pm

How to deal with a pop-up window

Post by todd5359 » Tue Oct 08, 2013 12:01 am

I have a pop-up logon window, and I want to implement "close" the window if it pops up and move to next recording module if it doesn't pop-up. I use user code module and it shows as follows. It works if the window pops up, but it doesn't work if the window doesn't pop-up. How can I exist this user-module and move to my next recording module if the window doesn't pop up?

Thanks a lot :P
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;

using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;

namespace TestWithPB
public partial class Recording1
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
private void Init()
// Your recording specific initialization code goes here.

public void UserCodeModule1()

var logOn = repo.LogOn.LogOn;
var cancel = repo.LogOn.Cancel;

if (logOn.Visible)
else {return;}


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

Re: How to deal with a pop-up window

Post by Support Team » Thu Oct 10, 2013 1:26 pm


I recommend to use our PopupWatcher class to implement this functionality.
Please take a look at Handling Unexpected Dialogs in our User Guide.

Markus (T)