I am using QTP 9.1 to automate a requisitioning tool's testing.
After recording various scripts, we have found that the tool dynamically changes technical field names from time to time. The description next to the field is not actually associated directly with the field, except that it does reference the other field's dynamicly assigned name in its outerhtml object property. I have been able to use the Expert View in QTP to get the appropriate value, but when I tell it to use the object referenced by that value, it tells me that the object repository does not have a reference like that. Should I be using a SetToProperty method in order to dynamically change the field name of my referenced object to match the outerhtml of the field description?
To "illustrate", I have text on a screen that says "Department". It has an outerhtml value of "<LABEL for=_9i>Department:</LABEL>" in one session, and "<LABEL for=_7z>Department:</LABEL>" in another session. There is a corresponding field in which I would like to have the requestor's name typed. It has an "html id" object property of _9i in the first session and _7z in the second session. I want to make it so that the _9i and _7z is pulled out of the description field and then used to select the department field and enter the value appropriately there that I pass it from my data table.
I have not tried SetToProperty as I am not overly familiar with it. I am not sure if I need that, or if I can update the object name using the regular expression in the object repository.
Any assistance would me much appreciated. Please let me know if I need to provide more environment info as well.
I would recommend learning the setTOProperty & getROProperty methods. In dynamic web applications there will be many occasions where certain properties of your objects will change. I use setTOProperty regularly to set values for properties on objects that change, where you get that value is up to you. Sounds like the getROProperty and some regex along with the setTOProperty would help you solve your problem.
I was able to find something interesting that was a tremendous help. Not all objects that are used need to be referenced in the Object Repository within QTP.
I was able to utilize a variable to store the outerHTML of one of my objects (the Label field). I then used an INSTR command and a MID command to get just the portion of that varibable that pertained to my target field's dynamic name. That value was stored in a variable called var_obofield.
I was then able to use the following syntax (full code with variables listed at bottom of message) to perform the selection on the target field using its html id value . . .thereby allowing me to perform a mthod on an object without actually having the object stored in the object repository: