Control with no name and ID

Ask general questions here.
din2dino
Posts: 12
Joined: Wed Nov 05, 2008 6:50 pm

Control with no name and ID

Post by din2dino » Wed Nov 05, 2008 8:26 pm

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?

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

Post by Support Team » Wed Nov 05, 2008 8:44 pm

Is this control within a web page?
Do you want to automate a web application? If yes please use RanorexWebSpy.

Jenö
Ranorex Team

din2dino
Posts: 12
Joined: Wed Nov 05, 2008 6:50 pm

Post by din2dino » Wed Nov 05, 2008 8:45 pm

This is not a web application. Its a desktop app.

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

Post by Support Team » Wed Nov 05, 2008 8:50 pm

What is the Element Role and Element Name of the text box?

Jenö
Ranorex Team

din2dino
Posts: 12
Joined: Wed Nov 05, 2008 6:50 pm

Post by din2dino » Wed Nov 05, 2008 8:54 pm

Element Role is Text (42)
And Element Name is blank. Nothing listed.

Class is Internet Explorer_Server

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

Post by Support Team » Wed Nov 05, 2008 9:06 pm

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

din2dino
Posts: 12
Joined: Wed Nov 05, 2008 6:50 pm

Post by din2dino » Wed Nov 05, 2008 9:24 pm

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.
:(

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

Post by Support Team » Thu Nov 06, 2008 11:13 am

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