We come across this situaltion quite frequently. How do we deal with a dynamic object/continuously changing object at the runtime. May be the object's properties are set dynamically at runtime through input parameters. We are now at a point where we cannot add this object to the OR (Object Repository).
So what's the solution?
It is simple, create a dynamic/runtime object.
How do I define/create a dynamic object?
- First Method:(method is explained inline)
Set newObject = Description.Create 'The above line declares a new object newObject("micclass").Value = "WebElement" 'The above line sets the type of object (Browser/Page/WebElement/Link etc), in this case it is a Web Element 'The below 3 lines set the Dynamic/Runtime properties of the object newObject("html tag").Value = "SPAN" newObject("class").Value = "radio-classic-ITEM-OFF" newObject("text").Value = Parameter("Text") 'Usage of the new Object Browser("Google").Window("Google").WebElement(newObject).Click
- Second Method
Browser("Google").Window("Google").WebElement("html tag:=SPAN", "class:=radio-classic-ITEM-OFF", "text:=" & Parameter("Text")).Click
More QTP scripts here...
What happend if i had Objekts with the same characteristics
ReplyDelete