不可编辑控件的变相解决方式
上一篇 /
下一篇 2009-09-03 16:12:56
/ 个人分类:自动化测试
)]X9xhO/e0 我们经常遇到有些编辑框不能直接赋值,比如日期输入框,所以在脚本编写时候需要编写一大操作脚本,参数化就更加麻烦,是否有一种方法可以快捷的进行操作
S1h2pG!W0问题分析:我们平时解决方法,往往是想各种办法去实现这个输入,其实编辑框无法输入是因为编辑框的readOnly=true,所以这次我们换个角度不是去想办法开锁,而是把锁撬掉。
o{"Q!CD$y0解决方法:修改目标编辑框的属性为readOnly=false,然后再执行set操作
R;A*uk#L0qtp脚本实例: 51Testing软件测试网;x]q%wm&Q?8Y
!O"g5ET
W051Testing软件测试网2qn+\[oLh
Function common_set_readonlyedit(obj_input,mes_input)
PgGtJ@7N0 Set bj=obj_input.Object51Testing软件测试网 L%rK.Jr:UD
old_set=obj.readOnly51Testing软件测试网'j,H"MHY}
DY
if old_set=true then
L%A7FrLSY#Y6N0 obj.readOnly=false
6GI r:sY[y@6S&e0 obj_input.set mes_input51Testing软件测试网)|"z;[zce` K~~
obj.readOnly=old_set
6l&] [s;ZC0 else51Testing软件测试网OriK{1C
obj_input.set mes_input51Testing软件测试网.T+OWZ&[Q z _3S2zO8R
end if51Testing软件测试网
]c K
UQto Jn0P:T
End Function
omkI#_0
51Testing软件测试网/qk_&U2xf)N X51Testing软件测试网 Ld;y;CD@p
ruby脚本实例: 51Testing软件测试网o({{ Q Uu
qv0E
Ja}z3S4^HR0
i|Yr0Z(G0def common_set_readonlyedit(obj,mes_input)51Testing软件测试网kA\ND`h,Z7f*c
old_set=obj.readOnly
Y!K
V9mQoiWQ0 if old_set==true51Testing软件测试网
t9v?M"v5x
obj.readOnly=false51Testing软件测试网4p9?8Ha"a3\7TwT-n,p
obj.value=mes_input51Testing软件测试网1oZ8W2@4Z`bf7R
obj.readOnly=old_set
"x)vRq$m4r0 else
nk5E{D*Q0 obj.value=mes_input51Testing软件测试网4c M+W,{iwm
end51Testing软件测试网A8x
a~PPr:I~
end51Testing软件测试网&q"v$[%X.Q3OP/L"Q
收藏
举报
TAG:
QTP
Ruby