Ranorex get struck on attempting to click a button in msgbox

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
ChrisDavid
Posts: 7
Joined: Wed Feb 19, 2014 3:27 pm

Ranorex get struck on attempting to click a button in msgbox

Post by ChrisDavid » Tue Dec 23, 2014 1:34 pm

Code: Select all

public void Handle_messagebox()
{

if(repo.Folder1.Button1Info.Exists())
{
	Report.Info("Found message box. Clicking on Ok button.");

	repo.Folder1.Button1.MoveTo();
	repo.Folder1.Button1.Click();	            
}
else
{
	Report.Info("Did not find Message box.");
}

}
I have above simple code but while executing it, Ranorex seems to be struck on identifying the button in the message box. 'If statement' gets executed(which means button is recognized) and the info message is displayed and then for some reason ranorex gets struck there and no action is performed forever. No 'item not found' error is thrown even. Its just struck for hours and no action is performed. Once the button is clicked manually, run seems to continue with next steps.

This is inconsistent, This passes sometimes and fails most of the times. Sometimes it gets struck in the 'if' statement itself, once button is clicked manually info message in else statement in displayed.

This happens particullary with this message box only, with other this kind of message/dialog box, it seems to be working fine.

Can anyone please clarify why this is happening and how we can rectify it?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex get struck on attempting to click a button in msgbox

Post by Support Team » Wed Dec 24, 2014 1:01 pm

Hi Chris,

Please make sure that the Use Cache property of the Folder1 reposiotry folder is set to false and just use either a RepoItem.MoveTo or a RepoItem.Click:
if(repo.Folder1.Button1Info.Exists())
{
   Report.Info("Found message box. Clicking on Ok button.");

   repo.Folder1.Button1.MoveTo();
   Mouse.Click();            
}
// OR:
if(repo.Folder1.Button1Info.Exists())
{
   Report.Info("Found message box. Clicking on Ok button.");

   repo.Folder1.Button1.Click();         
}
I hope this helps!

Regards,
Markus
.
Image

ChrisDavid
Posts: 7
Joined: Wed Feb 19, 2014 3:27 pm

Re: Ranorex get struck on attempting to click a button in msgbox

Post by ChrisDavid » Wed Dec 24, 2014 3:02 pm

Hi Markus,

Thanks for your response. 'Use Cache' property of the repository folder is set to False already.

The issue is inconsistent and we can not determine where it will fail. Sometimes it gets struck in 'If Statement', sometimes at Movteto() step, sometimes in click() step.

You first suggestion is working fine but sometimes it gets struck at the MoveTo step itself. Log during the run shows as its searching for the item but it does not fails after the search out time of the item, it keeps on searching the item forever and gets struck there. Why is this happening? Is there any other way to handle this?

I access my application from remote machine and so sometimes just using click() does not clicks the item correctly and so I have to use both MoveTo() and Click(). And so I cant use your 2nd suggestion.

Regards,
Chris

ChrisDavid
Posts: 7
Joined: Wed Feb 19, 2014 3:27 pm

Re: Ranorex get struck on attempting to click a button in msgbox

Post by ChrisDavid » Sat Dec 27, 2014 2:58 am

On performing few more trial and error on this I found out that it does not have anything to do with the item in the repository but just the appearance of this particular dialog box is making Ranorex to pause indefinitely.

In the code I removed all the lines that access this dialog and added a step to press enter key at the time when this dialog box will be displayed. But still somtimes Ranorex seems to be struck as soon the dialog is displayed. I just have Report.Info after this dialog is displayed. But still Report.Info step is also not executed.

Code: Select all

Report.Info("Previous dialog is closed");	   //This line is executed
Report.Info("Looking for next dialog");           //At this point dialog box will be displayed and no more code is executed(including this line) until the dialog box is closed manually.
Report.Info("Press enter key to close dialog");
Keyboard.Press(System.Windows.Forms.Keys.Enter);
In the above code, first line is executed and then the log gets struck there and no more action is performed by ranorex after the dialog is displayed. Next line is just a report.info line which is also not executed. Ranorex gets struck there for indefinitely. Once the dialog is closed by manual intervention, run continues from where it was struck.

This is not consistent, happens once in 5 times but when it happens, its getting struck forever which is causing lots of trouble for us. Why does the display of a particular item is making ranorex struck there forever until the item is closed? How to handle it?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex get struck on attempting to click a button in msgbox

Post by Support Team » Mon Dec 29, 2014 2:13 pm

Hi Chris,

That's weird, it sounds like a problem with the main thread of your application, could it be that the main thread is paused when the specific dialogue is shown?
May I also ask you what kind of application you test, a WPF application?
Would it be possible to send us a sample application which allows us to reproduce the issue on our machine?

Regards,
Markus
.
Image

dhale
Posts: 15
Joined: Thu Feb 27, 2014 7:33 pm

Re: Ranorex get struck on attempting to click a button in msgbox

Post by dhale » Tue Dec 30, 2014 6:55 pm

Some additional information about the issue:
This is a WinForms app, using .net 4.0. The issue is random, sometimes happens right away, sometimes late into the test run. Caching is off for the dialog in question. Happens on both 32 and 64 bit Win7 workstations.

It appears Ranorex is hung at creating the adapter for the ok button best I can tell via the debugger within Ranorex.
Specifically, when I paused the test run when it hangs and look at the call stack, it is hung in the repository method

Code: Select all

public virtual Ranorex.Button Ok_Button
            {
                get
                {
                    return _ok_buttonInfo.CreateAdapter<Ranorex.Button>(true);
                }
            }
The message box that is causing the issue is configured as follows: (note descriptive text has been edited out)

Code: Select all

MessageBox.Show("SomeText: More text.", "Alert text",
                        MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
I suspect (but am unsure) that the issue may be related to MessageBoxOptions.DefaultDesktopOnly option specified. When I look at threads, I see that Main is in Location: get_Ok_Button, priority is: normal, and Frozen is: No

If we manually dismiss the dialog, the test run will continue without fail.

I have taken a snapshot of the dialog if it may help any.

dhale
Posts: 15
Joined: Thu Feb 27, 2014 7:33 pm

Re: Ranorex get struck on attempting to click a button in msgbox

Post by dhale » Tue Dec 30, 2014 10:19 pm

I just tried a slightly different approach, via pop up watcher class to see if that would behave any different - no luck. Same issue. Random freezing after multiple sucess when late in the test run. Still gets stuck in the repository when trying to create the adapter.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex get struck on attempting to click a button in msgbox

Post by Support Team » Wed Jan 07, 2015 2:06 pm

Hi dhale,

We analyzed the issue and this is indeed connected to the MessageBoxOptions, in specific to the "DefaultDesktopOnly" member.
It works as expected when you don't use this option at all or when you use one of the other members since the "DefaultDesktopOnly" option somehow creates another process for the MessageBox and makes the main form "Not Responding" and furthermore forces Ranorex to freeze since the MSAA peer hangs.

I would therefore highly recommend to not use the "MessageBoxOptions.DefaultDesktopOnly" attribute.

Regards,
Markus
.
Image

dhale
Posts: 15
Joined: Thu Feb 27, 2014 7:33 pm

Re: Ranorex get struck on attempting to click a button in msgbox

Post by dhale » Wed Jan 07, 2015 4:33 pm

Thanks for the confirmation.
We will work with our developers to get around this particular issue.