Using dynamically named controls
I'm trying to write some test automation for a web application. Each of our clients uses the same ASP/ASPX pages, but based on information read from the database, the final HTML of each page is customized on a per client basis - so for instance, every client has a dropdown control with a caption that says "Location", but the items in that control and the name of the control itself are dynamically generated on a per-client basis.
I'm trying to write automation that can work equally well on all our clients, and as a result, can't refer to many of our controls by name in my scripts. I've been trying to access the controls by their indices, but have had mixed success. I can find the controls successfully and figure out what their page index is, and once I've done this, use script like
to refer to the controls. However, I can't use actions of controls when referring to them using an index. For a given dropdown control,
page.document.all.ClientOneLocationDropdown.Click ("menu item")
works fine, but
doesn't work at all. Does anyone have any suggestions for how I can access control actions successfully without specifically referring to them by name?
Re: Using dynamically named controls
Please try using the Child method of an object as follows:
Btw, if you need to loop through all of the children of an object you can use its ChildCount property and the Child method like this:
for i = 0 to page.document.all.ChildCount - 1
Set Control = page.document.all.Child(i)
'do stuff here with the Control
Save on AutomatedQA Products