不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。                                           it is no use doing what you like, you have got to like what you do.

针对popups类对话框的watir处理方法之二

上一篇 / 下一篇  2009-09-16 15:25:30 / 个人分类:ruby_watir

每日随笔
  • 每日随笔:

s6g%n.C c2n0针对该类对话框的处理方式:51Testing软件测试网){@)C,T!yj }
require 'watir'
lij$L9i5F0require 'win32ole'
Z3[PdY&N0require 'watir/WindowHelper'
W6Y_%IP5Yt0# 登陆
/\-m8NNA$V3[ D8uKz0$ie_site ='http://members.shaw.ca/paul_rogers/watir_tests/popups1.html'51Testing软件测试网d O}4X+EAFu
#$f = 'E:\WorkSpace\00-Automation\03_MOA\02_Branches\JiangXi\V2.9.1\Lib\db1.vbs'51Testing软件测试网 F0] Ca;pis
$ie = Watir::IE.new
3r"S;s1_ XW5Ay0$ie.goto $ie_site
Z/D`.Q-QT Y0
$F [E-p+uw Zw0f0#遍历所有的按钮控件
R q4Ar%S:|$q!M p0#$ie.buttons.each {|b| puts b.to_s}
e|.m?5ge9s051Testing软件测试网W@mUSjy
$ie.button(:value,"Confirm").click_no_wait
W7d2qv#x0sleep(7)
:]Ft*B!sr {0autoit = WIN32OLE.new("autoitx3.control")
5l~1eZg3a0$a = autoit.WinWait("Microsoft Internet Explorer","",1)
gE#c/G mA b/z0puts $a
{yK/IIRk,I_0$c = autoit.ControlClick("Microsoft Internet Explorer","确定","Button1")51Testing软件测试网&F1a"N}pH(oa
puts $c
s9M/gR*a+j D(S0
MMS k5FNV)a0$a $c 全部为1 说明结果通过。
va8j?XYKa4en z0#相关函数用法:51Testing软件测试网zn[i0[U
51Testing软件测试网z JYw*F0VF|
=begin51Testing软件测试网 @0i@uj4Qo
defclick_no_wait51Testing软件测试网
j
Z2UvZa
51Testing软件测试网,u@[ QGodJ
assert_enabled
8n6iR~.H7?-nh0^Y0highlight(:set)51Testing软件测试网5F2X0|g6dOs0s[
object="#{self.class}.new(self, :unique_number, #{self.unique_number})"51Testing软件测试网5xQ/c3\ul[ M-D3bnI
@page_container.eval_in_spawned_process(object+".click!")51Testing软件测试网*K8E5@ MzTDg
highlight(:clear)51Testing软件测试网o$|bjgz;yFK
51Testing软件测试网^V$]#`3Yu:g
end
A5m O*d7[$e(wN+r(h051Testing软件测试网?I(l"v4bL3Wq_X
=end
DIavu T0C4nI s0
NZ#| X_H#Q"xr0sleep:
;Z;l5k-h-F-~F_-P[8u051Testing软件测试网Qd#yg#P+PdS
sleep是ruby中自带的函数,它的使用方法是sleep([sec]),意思是:使程序暂停sec秒,省略sec时,
$y5H~.V;[ ub*D'b S0若没有显示地(sigalrm或其他线程发出的thread#run)终止睡眠的话,将一直sleep下去,51Testing软件测试网hE j-ka/dl
返回值是实际睡眠的秒数(整数)。
+n5[Z9{9g/u/t'R051Testing软件测试网q[[8M.CB
同wait比较:
&D_ |OG3fC'h`0wait:
Ol.B{k%M-l0wait是watir中IE类中封装好的函数,Watir API Reference中这样解释它:51Testing软件测试网 TU-OEg'sc.Ax+S p
Block execution until the page has loaded ,
.m \"Z&uG&yAh0翻译成中文就是:直到页面加载完成才向下执行;51Testing软件测试网)Sv gL&Zb3N

2wk9h#tw` b BNd0
~+qQmO#T,H LM0
(K9C,i%@'G0
u2NU-n+B&Eq!_Q-w0
O;d0U;IBGI:b051Testing软件测试网|+n1N)Eoa
51Testing软件测试网'JN f(q,uFJp

p ZHLH j&Ul ^0

TAG:

 

评分:0

我来说两句

Open Toolbar