QTP: Description & Programming Interface itself

First, the code optimization method

Code newline _
refining common code with ... end with

Second, the conventional method of object

GetRoProperty:取得实际对象的某个属性的值
GetToProperty:取得仓库对象的某个属性的值
GetToProperties:取得仓库对象的所有属性的值
SetToProperty:设置仓库对象的某个属性的值

Third, the description of programming 

'对象库编程的代码
 Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").Set "软件测试"
 Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").Click

'描述性编程:直接描述的代码
 Browser("micClass:=Browser").Page("micClass:=Page").WebEdit("html tag:=INPUT","name:=wd").Set "软件测试"
 Browser("micClass:=Browser").Page("micClass:=Page").WebButton("html tag:=INPUT","name:=百度一下").Click

Fourth, the package interface and the interface itself

''''''''''''封装接口和自身接口使用案例
'修改WebButton对象的自身接口属性innerText
 Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").Object.innerText="百度一下下下"


''''''''''''调用WebButton对象的自身接口的方法Click
 Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").Object.Click


''''''''''''通过调用自身接口的方式来获取动态运行时的编辑框的值
 getContent = Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").Object.value
 msgbox getContent

''''''''''''使用自身接口进行赋值操作
 Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").Object.value = "软件测试"

''''''''''''使用封装接口进行赋值操作
 Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").Set "软件测试"

 

 

Published 349 original articles · won praise 161 · views 190 000 +

Guess you like

Origin blog.csdn.net/qq_42192693/article/details/103468267