Tuesday, April 7, 2009

Dynamic DP


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.



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.

Get DynamicDP 1.0

Download Link



Happy Automation :)








15 comments:

  1. @Ketan,
    I am expecting your feedback/suggestions after you use it.

    ReplyDelete
  2. Hi Manish,
    i was looking something like what you made.. it is simply wonderful.. :)

    Thanks!!!

    ReplyDelete
  3. hey,
    this is very nice framework.. and nice efforts thanks a lot... can we have java object recognition here ?

    ReplyDelete
  4. @easy,
    thanks for appreciation,
    this framework is purely dynamic and can be work with any types of object.
    In version 1.0 i have only added web object collection ..
    if you see the database you will find swfobject also but its ROproperty table is not build..

    similarly you can yourself read all properties from java/oracle/.net pluging from windows registry and add it or manually.. i have another HTA to do this.

    may be in next version .. stay in touch

    ReplyDelete
  5. its awesome...
    thanks :)

    ReplyDelete
  6. hey manish..
    it worked like charm :)
    i must say everyone should talk benefit of this UI ...
    we should name this UI for DP or UI4DP ;-)
    three cheers to you..

    ReplyDelete
  7. I gave demo to my management and now
    We have implemented it to my new project..
    please tell me how to use this to our old projects ? is it possible ?

    ReplyDelete
  8. Manish,
    I downloaded and got the second screen,but in that screen iam not seeing any objects the drop down for Webctrl is blank..no objects in the drop down.Iam not able to figure out after getting the second screen how to add the objects.I clicked the submit button nothing happens on that screen.I am interested this kind of dynamic objects and want to implement the same.Could you please let me know with more details as how to add the objects.
    thanks
    BR

    ReplyDelete
  9. @Anonymous,
    I just downloaded this release, it is running absolutely fine on win 2000, win xp (not tested on vista)...
    Well I guess, i got it what you are trying to do.. did you read "Readme.txt" ?
    you must be using "DPTree.html" ? if this is the case you need to follow this following point derived from "Readme" file
    2) Update database location in db.vbs location "" 'for html verson not needed for HTA.

    Uncomment this line from DB.vbs
    myDataPath = "D:\DynamicDP3\MyDynamicObjects" ' uncomment this line for html version

    And comment below line.
    myDataPath = CreateObject("Scripting.FileSystemObject").GetFolder(".").Path

    Thats all :)
    Actually i should put this line above the early one... but why you are not using HTA version…
    Please also let me know if this worked ?
    -
    Manish

    ReplyDelete
  10. hey manish,
    this is really nice code, i enjoyed it and made some additional changes in this script, will mail you so can be updated, can't this could be githubbed ? so other can upload it there's as well..
    I have heard you claimed about some Dynamic Dom, what is that and when that is coming ?

    ReplyDelete
  11. Manish,

    Can we use your dynamic DP in other tools?

    Will it support?

    Thanks,

    Prince3105

    ReplyDelete
  12. @Prince3105,
    DP is a sole concept of QTP and this framework is made by keeping QTP's in mind. core “description” class and its "create method" which is used by the framework itself is purely QTP specific so it will not help you for other tool...

    but the good part is this is open source, read and understand the code, if need help get back to me anytime, and modify for other tools...
    BTW, for which automation tool you wanted to use this framework ?

    ReplyDelete
  13. I am waorking on Watir. After two years completion of happy married life with QTP and VBscript(What a user friendly environment) i was forced to work on open source technology due to recession:-(

    I couldn't use watir's libraries extensively in my script. Watir supports Win32 components. Thats why i am concentrating on Component Object modal. Almost i have crossed the half of the way towards my goal.

    I am using open source and freeware libraries in my script, like Tarun's API, AutoIT - COM, OpenOffice......


    Still am lacking to collect object's properties. By using IE developer tool bar i am writing object's properties. Usually it takes more time to write descriptions. That's why i asked you about your DP whether its usage in Watir is possible or not. I believe yours dynamic DOM would help me.

    Thanks,
    Prince3105

    ReplyDelete
  14. I dont know how to run it with qtp - I need step by step instructions like
    1. copy this bit of code to action

    because I just copies the code above into a test and ran it

    ReplyDelete

StatCounter