Page 1 of 1

Control with no name and ID

Posted: Wed Nov 05, 2008 8:26 pm
by din2dino
How can I get the contrl of an item that has no name/id shown. Its actually a text box and spy shows no name and Id except for class is Internet Explorer_Server.

Whats the solution?

Posted: Wed Nov 05, 2008 8:44 pm
by Support Team
Is this control within a web page?
Do you want to automate a web application? If yes please use RanorexWebSpy.

Jenö
Ranorex Team

Posted: Wed Nov 05, 2008 8:45 pm
by din2dino
This is not a web application. Its a desktop app.

Posted: Wed Nov 05, 2008 8:50 pm
by Support Team
What is the Element Role and Element Name of the text box?

Jenö
Ranorex Team

Posted: Wed Nov 05, 2008 8:54 pm
by din2dino
Element Role is Text (42)
And Element Name is blank. Nothing listed.

Class is Internet Explorer_Server

Posted: Wed Nov 05, 2008 9:06 pm
by Support Team
You can use the following code, if the index of the text box remains the same:

1. Read all text boxes with Element.FindChildren:

Code: Select all

Element[] editFields = control.Element.FindChildren(Role.Text); 
2. Use the index to get/set the value of the text.

Code: Select all

editFields[index].Value = "new text";
Hope this works.

Jenö
Ranorex Team

Posted: Wed Nov 05, 2008 9:24 pm
by din2dino
Thanks for this sample. I did actually try this. However I get a lot of such Role.Text elements that I cant manage to know the index of the one I need.
:(

Posted: Thu Nov 06, 2008 11:13 am
by Support Team
You can search for controls using their ClassName, too. Just pass the classname as a parameter to the Form/Control.FindClassName(string className) method.

Regards,
Alex
Ranorex Support Team