Working as a Test automation engineer from last few years using various technologies with an Open source Attitude, I have always tried to develop reusable components which will help user to reuse there efforts and can be easily maintain and optimize test running.
While working with Quick Test Professional® I found they have very good concepts of Object repository which contain physical properties collections of object to identify it easily.
QTP being following Microsoft methodology of making user friendly UI, so they have provided an interface which can be used to create objects which can be used at runtime.
“Another example of there UI holiness is “keyword view”. I myself don’t understand how does it really works, better if they would have spent some more time on providing useful features like batter auto-complete with batter IntelliSense, code region (code collapse), multiple test development interface”
Object Repository is a wonderful feature and helps while working with some static, type’s objects but while working with dynamic (run-time) objects their main identification properties are dynamically updated, which creates cumbersome in managing tests. But QTP again have wonderful Solution to that, which we all known as “Descriptive programming”.
Descriptive programming (DP), as it is named, it does the same work, while working with this, user just needs to provide attributes values of there objects, to “description” class which is having only single public method called “create”.
DP is easy to use but it increases the lines of codes, again it has comparatively slower execution then precompiled object repository. While Working with DP I also found problem of “QTP loses its web object reference” on navigation /Post back. Which also have been faced by a large QTP community while working on different applications. But for a complex and large size application DP is the best approach which can be used.
"There are many articles already present for DP saying its advantages and disadvantages, and its needs, so let’s do not to reinvent wheel."
How effectively use DP
This white paper is containing a DP approach which will identify How to solve DP related issues, it also have a batter object definition structures which helps to code fast and optimized why with easy maintainability and provide flawless execution, which is a robust system and allow users to play with the Objects on the fly.
CodeName : DynamicDP 1.0
While working with QTP from long time and being connected to community I have seen many experts are creating dynamic objects outside the QTP, to achieve this they use xml, some use CSV (bad idea) but most of them uses excel spreadsheet which is more reliable and can be queried directly using FSO cell reference or by ADO connection.
Some time back I had a talk with a quite senior community member asking how you use your objects in your framework in a forum thread. Unexpectedly after a couple of days I got an email with an attached excel sheet screenshot and found that addressed forum member shared his idea with me. He was keeping those objects properties in excel sheet and creating object dynamically.
Okye, but it wasn’t so great manually managing those big sized excel sheet and its maintenance, but somehow replacing OR for that framework didn’t impressed me more.
This initiated a thought to have something which uses even better approach to carry objects and have a strong reason to use it.
Dynamic DP is a GUI application which works on MSHTA and uses internal explorer internally, it is made on javascript, vbscript , html and external third party library like jQuery and a jQuery treeview, context menu, thickbox plugins. It has a similar front end similar to OR (more UI part needs to be added) .
By Double clicking DPTree.hta it will popup same like screen 1 without tree nodes.
Screen 1 Clicking on root node it will appear a Thickbox which has “Parent ID” = 0, normally a browser object like Screen2.
New objects can be stand alone without parent objects and while using those object we can provide parents to it.
ones object gets saved it will appear under root node. right click will open a context menu currently three options are displayed, ADD , EDIT and REMOVE
Screen 3
Once object get saved can click (normal left click) on it to fill its description.
All done ! now we are ready to use these dynamically created object.
How do we use dyamicDP in our Test
The First Step
'this is required statement and it should come on the top of the user action
ObjCollection.BuildObjTree()
Working Set
'============== ways of Using Objects ===============
'Using objects Style 1 [MyObjID + Ctrl keyword]
myBrowserCtrl.highlight()
myPageCtrl.highlight()
myWebEditCtrl.highlight()
'Using Objects Style 2 [MyObjID as a DP object]
Browser(myBrowser).highlight()
Browser(myBrowser).page(myPage).highlight()
Browser(myBrowser).page(myPage).WebEdit(myWebEdit).highlight()
'Using Objects Style 3 [Mixed Approch]
myPageCtrl.WebEdit(myWebEdit).highlight()
'=============================================
'=================== Some Invalid ways it will produce error ===========================
myPageCtrl.myWebEditCtrl.highlight() 'Error
' myWebEditCtrl is Already a Qualified Control and its Parents is Already decidede
' but the same control can be used as A [MyObjID as a DP object] which is stated above even for the other parents.
'===================================================================================
while Creating Object we have to BE CAREFUL selecting the Object Name
if we use the same object Name for other or New object the System will overwite it
Functional Reference
'******************************************************************
'**** ObjCollection.BuildObjTree()
'**** ObjCollection.UpdateObj(ObjName, propName, propVal)
'**** ObjCollection.CopyObj(NewObjName, ObjName, ObjParentName)
'**** ObjCollection.RemoveProps(ObjName, propName, propVal)
'**** ObjCollection.AddObj(ObjParentName, ObjName, ObjType, ObjDesc)
'******************************************************************
'this is to build three.
GoogleCtrl.highlight()
GoogleCtrl.sync 'I try always try to add sync in my AUT test framework
ObjCollection.UpdateObj "Link1","innertext","About Google"
Link1Ctrl.highlight() ' it will click About google link
GoogleCtrl.sync
ObjCollection.CopyObj "Link2","Link1","GooglePage"
Link2Ctrl.highlight() 'it will create another link with name Link2 and will do the same opration which can be done by Link1
ObjCollection.RemoveProps "Link1","innertext"
ObjCollection.UpdateObj "Link1","name","Privacy"
Link1Ctrl.highlight() 'it will open "Privacy" link but using different object identification properties
SearchTextboxCtrl.set("Manish Bansal")
SearchButtonCtrl.highlight()
ObjCollection.AddObj "GooglePage","Radio1","WebRadioGroup","name=meta"
Radio1Ctrl.select "#1"
'******************************************************************
Integration
Please go through Read me file shipped along with core.
Happy Automation :)