Finding radio button on dynamically changing form

Ranorex Spy, Recorder, and Studio.
[email protected]
Posts: 2
Joined: Wed Dec 11, 2013 3:42 pm

Finding radio button on dynamically changing form

Post by [email protected] » Wed Dec 11, 2013 4:19 pm

Hi,

we have a problem with ranorex correctly identifying radio button on the following dialog. The dialog's lower content (edit boxes and radio buttons) is dynamically displayed depending on the value selectred in the combobox.
exportdialogexcel.png
exportdialogexcel.png (34.74 KiB) Viewed 1129 times
exportdialoge.png
exportdialoge.png (37.43 KiB) Viewed 1129 times
We use the following code to access the radio buttons.
Ranorex.Form TopMostForm = Host.Local.FindSingle<Ranorex.Form>("/form");

sSearchString=".//radiobutton[@class='Button' and @accessiblename~'^"+sParameter+".*']";		
			
if (TopMostForm.TryFindSingle<Ranorex.RadioButton>(sSearchString,5000,out myRadioButton)== true)
{
	Report.Info("Radio button for parameter '"+sParameter+"' found");
        retVal=true;
}
else
{
	retVal=false;
	Log.LogEnd(retVal);
        .....
}				
        Log.LogEnd(retVal);
	return myRadioButton;
The thing is when we open the dialog and access the radio button right away everything works fine. Then we change the value in the combo box which leads the radio buttons to appear further down the form. If we run that code again afterwars the cursor will click on the old position of the radio button and miss the current one.

Any ideas how to solve this issue?

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

Re: Finding radio button on dynamically changing form

Post by Support Team » Thu Dec 12, 2013 4:49 pm

Hello Christoph,

It might be that the content's position is not updated after changing the combobox.
Please try to add a short delay after your change.

Could you please post or send us a Ranorex Snapshot of your application?
This would help us in analyzing your issue.
Please take a look at our User Guide for more information on how to create snapshot files.

Regards,
Markus (T)
.
Image

[email protected]
Posts: 2
Joined: Wed Dec 11, 2013 3:42 pm

Re: Finding radio button on dynamically changing form

Post by [email protected] » Fri Dec 13, 2013 2:38 pm

Thank you for your reply.
Yes, I already thought I might have to wait a bit for the position to be updated.
But I think I found the solution:

When using the Find method of the adapter instead of the tryfindsingle method, i discovered i get a list of two radio buttons matching my xpath search string.
One button has the old coordinates and the other has the new ones. My fix is to use the find method and then continue working with the last element of the list, which is the latest one in my case.

Can you confirm if this is the way to go?

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

Re: Finding radio button on dynamically changing form

Post by Support Team » Mon Dec 16, 2013 5:01 pm

Hello Christoph,

Thank you for your good news :-)
You could of course use your approach to find your correct radio button.

It would be great if you could post a Ranorex Snapshot of your application containing both radio buttons.
This would help us to find out why this happened.

Regards,
Markus (T)
.
Image