In Part-1 of this post, we discussed about Static DP. Let’s look into Dynamic DP in this part.
- Description Object stores the properties and values of a particular object in an instance of that object. So it become easy to use it in the statement.
- Description Object are used with ChildObjects (very useful method) of QTP.
- It’s more useful if you are using multiple properties to identify object. As you will use only instance name in your statement, your code looks more organized.
- It’s very handy if you are using index property for object identification (we’ll discuss later)
Dim oBrowser, oPage, oButton ‘ declaration is not mandatory but good practice!
Set oBrowser = Description.Create
Set oPage = Description.Create
Set oButton = Description.Create
Now we’ll add identification properties & values to these objects.
oBrowser(“name”).value = “myBro”
oPage(“title”).value = “myPage”
oButton(“name”).value = “Enter”
oButton(“type”).value = “Submit”
oButton(“x”).value = “301”
And that’s it! Our objects are now ready to use now. So, here we go…
Browser(oBrowser).page(oPage).webbutton(oButton).click
Tedious?? I know! 🙂
Explore the following code to make the things clear…
- Browser(“myBro”).page(“myPage”).webbutton(“Enter”).click – OR approach
- Browser(“name:=myBro”).page(“title:=myPage”).webbutton(“name:=Enter”,”type:= Submit”).click – Static DP.
- Browser(oBrowser).page(oPage).webbutton(oButton).click – Dynamic DP
Lets see how…
Browser(“myBro”).page(“title:=myPage”).webbutton(oButton).click
In above statement, we have used all 3 ways..
Browser – Object Repository
Page – Static DP
webbutton – Dynamic DP
Ohhh I see!!
Only point to take care here is that OR can’t be used after DP.
Okey guys.. In next part of post, we’ll discuss pros & cons of each way and other good stuff about DP.
In case of any queries, please post your comments.
Nice work..waiting for next post!!
Its really a nice post!!!
Very helpful information!!! Thanks much.
it's a very nice post….thanks ,keep posting
it's very nice post… and very helpful. Thanks a lot
capturebitmap(fname.bmp), if i use this command and run second time i get error msg that file exists. what is the solution to avoid this and supply another file name dynamically.
Hi Admin,
Its really nice content and very help.
Can you please accommodate my below request.
Can you please post any article in Webtable in QTP, all its methods and examples as you have mentioned in other articles.I hope this suggestion will come soon in post.
Thanks.
Its really gives the difference between OR,Static & Dynamic which really helps to learn.Hope you ppl really giving the best materials.
Hi Madhu,
Use the time stamp for the filename(unique for everytime) then u wont get the error.
Great articles…thanks for sharing
useful information…thanks
Excellent Stuff dude!!Got to learn a lot of useful info.Keep Posting abt QTP!!:)
hi.. i want to know that for login page of gmail also we will go for dyanamic DP or static programming?
i know how to write static DP.. but have problem in dyanmic DP… if suppose we have so many users data in datatable then hw can i write using dyanamic DR.. pls write here ,,, thanks in adv
I appreciate your work
Excellent Stuff…..Got to learn a lot of useful info.Keep Posting abt QTP!!:)
thank you all!!
good post
very good clearly explained the things
By reading this blog, you are learning directly with me!! Happy to help if you have any question..