如果晚上月亮升起的时候,月光照到我的门口,我希望月光女神能满足我一个愿望,我想要一双人类的手。我想用我的双手把我的爱人紧紧地拥在怀中,哪怕只有一次。如果我从来没有品尝过温暖的感觉,也许我不会这样寒冷;如果我从没有感受过爱情的甜美,我也许就不会这样地痛苦。如果我没有遇到善良的佩格,如果我从来不曾离开过我的房间,我就不会知道我原来是这样的孤独.

QTP描述型编程--学习

上一篇 / 下一篇  2012-02-25 22:20:29 / 个人分类:QTP

l0nv.Z$[ r#@0'行描述方式,只要用SPY探测出对象的属性,不用捕获在对象库中51Testing软件测试网.k;^M8Y_w:m c
'下面是简单的小飞机订票代码,当然代码还可以优化这里只是为了熟悉行描述编程的思想
*m{4k9Zy[9n\R)h0systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
ZRP^~;` d0dialog("text:=Login").winedit("attached text:=Agent name:").Set "mercury"51Testing软件测试网7q.L,u!Uou}
dialog("text:=Login").winedit("attached text:=Password:").Set "mercury"
|)k T&m B&q#[ Ij0dialog("text:=Login").winbutton("text:=OK").Click '登录51Testing软件测试网`lyK6@oX;Z1n
wait 2
:DVP B$CX(ms3t)m0window("text:=Flight Reservation").ActiveX("acx_name:=MaskEdBox").Type "121212"
ftNW"{\/@GMb0window("text:=Flight Reservation").WinComboBox("attached text:=Fly From:").select  "London"
U.j3] j:d g'dG)Ml^0window("text:=Flight Reservation").WinComboBox("attached text:=Fly To:").select  "Paris"
r8KJ?e2ug Q0window("text:=Flight Reservation").WinButton("text:=FLIGHT").Click

~]_[ cP9I9QL051Testing软件测试网%T*R'P*XGvE[

window("text:=Flight Reservation").Dialog("regexpwndtitle:=Flights Table").WinList("attached text:=From").Select "12510   LON   12:48 PM   PAR   02:48 PM   AF     $165.60"51Testing软件测试网.P[up@;f
window("text:=Flight Reservation").Dialog("regexpwndtitle:=Flights Table").WinButton("text:=OK").Click51Testing软件测试网WWx2?-? @\
window("text:=Flight Reservation").WinEdit("attached text:=Name:").Set "test"51Testing软件测试网']9W'U]3WJ9F
window("text:=Flight Reservation").WinRadioButton("text:=First ").Click51Testing软件测试网)U+Y#F6p6jGT)D
'对象描述方式:此方法也无需添加对象在库中,对无法识别的对象可以采用此法
GJtO3]k4T0'Flight登录演示程序51Testing软件测试网&P@g9}8a0i7F g U
systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
{qcv_9Tt0Set penLog=description.Create()51Testing软件测试网[;r N{ JN6q,k(R
OpenLog("text").value="Login"51Testing软件测试网a9d [1E3gv~#u6y

nwa0sc#q uj T0Set username=description.Create()
Pm'B/Z#f"j0username("attached text").value="Agent Name:"51Testing软件测试网*t!vJ;KY l.O]?
dialog(openlog).winEdit(username).Set "mercury"

m e&amO6S051Testing软件测试网\HF:M b'l`

Set passwd=description.Create()
;?4K)r/wV6L)O6CV0passwd("attached text").value="Password:"
!@;X y&N/htZe0dialog(openlog).winEdit(passwd).Set "mercury"

R3]+@@2s*D6qWU_051Testing软件测试网.gsE:t[J

Set logbutton=description.Create()
XE6W5Ccq7\0logbutton("text").value="OK"
+Bj-W#Gn:YDXq f0dialog(openlog).winbutton(logbutton).Click
c.W+q;vGQu'QVj},R0

SorTH@l KB0

TAG:

 

评分:0

我来说两句

Open Toolbar