What is descriptive programming (Programmatic Desc

2019-02-18 12:12发布

What is descriptive programming in QTP?

标签: qtp hp-uft
16条回答
祖国的老花朵
2楼-- · 2019-02-18 13:13

Browser("title:=Google").Page("title:=Google").Link("text:=Advanced Search").Click is not a Descriptive programming, it is bad practise. Parameters should be separated from code, so you change them in 1 place, Object Repository file in this case.

What is Descriptive programming - when you use Description object:

Dim oDesc        'Description Object
Dim colObject    'Object Collection

Set oDesc = Description.Create
oDesc( "micclass" ).value = "Link"
oDesc( "text" ).value = ".*ma.*"  'Images
oDesc( "text" ).regularExpression = False

Set colObject = Browser( "Google").Page("Google").ChildObjects( oDesc )

So idea is to use description to get collection and search for your element in that collection.

查看更多
太酷不给撩
3楼-- · 2019-02-18 13:13

Writing descriptive level programming for the qtp

查看更多
等我变得足够好
4楼-- · 2019-02-18 13:14

Descriptive programming is used in many scenarios like -> When QTP is not able to identify objects from properties value stored in Object Repository. -> When user do not want to use object repository or bypass it. -> When user wants to write a piece of code that can run on more than one website. For eg.when we want to print the name of all link on Google or yahoo, we can use same piece of code using common property value

It is used in two ways 1. Static Descriptive programming Here we use properties and values directly in test script to access an object.For eg. Browser("micClass:=.....").Page("micClass:=...").Link("micClass:=...")

Note: We can start Descriptive programming at any time, but once started we can not use Object Repository till the line is finished.
  1. Dynamic Descriptive programming Here we create a description object and then operate on that. For eg. Set objTest = Description.Create objTest("micClass").Value = "Link" objTest("name").value = "Click Here"

Regards Dheeraj

Mindfire Solutions, India

查看更多
forever°为你锁心
5楼-- · 2019-02-18 13:15

Descriptive programming is used when you want to perform an operation on an object that is not present in the object repository.

Setting the value of a Text Box

Browser(“Browser”).Page(“Page”).WebEdit(“Name:=textbox_name”,”html tag:=INPUT”).set “My New value”


Read More
Check out this extensive article about the topic
http://www.learnqtp.com/descriptive-programming-simplified/

查看更多
登录 后发表回答