不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。
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
51Testing软件测试网c-}a5ii@针对该类对话框的处理方式:
51Testing软件测试网)^fJv"e:H-F,@0|
jrequire 'watir'
51Testing软件测试网L
L2pRkZ9Yshz+B-Orequire 'win32ole'
wl.r*Nn ^zk/Z0require 'watir/WindowHelper'
!K$?x
]+n+P%HzI2i0# 登陆
g8[Q*F?o#r)R+~0$ie_site ='http://members.shaw.ca/paul_rogers/watir_tests/popups1.html'
51Testing软件测试网4qq&ec,BVKC#$f = 'E:\WorkSpace\00-Automation\03_MOA\02_Branches\JiangXi\V2.9.1\Lib\db1.vbs'
"NR L/L~0$ie = Watir::IE.new
51Testing软件测试网!u^Hf`7m4FD;R$ie.goto $ie_site
51Testing软件测试网?G[9Cq-z2wva/Y|y0#遍历所有的按钮控件
51Testing软件测试网?8E6ogk+L~7b-zU#$ie.buttons.each {|b| puts b.to_s}
51Testing软件测试网-\-s+|p iZh&Y51Testing软件测试网2L:{$\?5q$ie.button(:value,"Confirm").click_no_wait
51Testing软件测试网YKO(L*Q-A$h~9XG _sleep(7)
Y4jqX']9I0autoit = WIN32OLE.new("autoitx3.control")
51Testing软件测试网U*iFT`z{*L4O$a = autoit.WinWait("Microsoft Internet Explorer","",1)
51Testing软件测试网C&s
a!w$F5O
Cputs $a
O/]5p%n*}
L1Uk8y'X6{-m0$c = autoit.ControlClick("Microsoft Internet Explorer","确定","Button1")
J;s b,}i wc$~*g+x'U0puts $c
3}|L1T.? e.@^051Testing软件测试网yO~ sJ3Bql$a $c 全部为1 说明结果通过。
CH)RPbe,f0#相关函数用法:
k
F;o1P3~051Testing软件测试网/Jd+|4N%R$c-{`Zs=begin
\ _8p[cv p0defclick_no_wait51Testing软件测试网({g/C'a2E t)KC1L#J
51Testing软件测试网,|}UE4Il-L
assert_enabled51Testing软件测试网 MU\:Z`W
highlight(:set)
*e lw#|7A TU%O0object="#{self.class}.new(self, :unique_number, #{self.unique_number})"51Testing软件测试网-rew7D+v"S6U4`&h4KT
@page_container.eval_in_spawned_process(object+".click!")51Testing软件测试网Xb.|R4zq6m$OF
highlight(:clear)
%{QVyO051Testing软件测试网.dDs5O(t5Yk
end
%sTJT#V CG0
8n\-f Dyxo#{T0=end
i!R'Jz%X"ga%C1e*V1Og0
V1]h T}K0sleep:
u I zxc eI5m051Testing软件测试网(baFc&o
?
sleep是ruby中自带的函数,它的使用方法是sleep([sec]),意思是:使程序暂停sec秒,省略sec时,
6Z2G2];t/oD.K0若没有显示地(sigalrm或其他线程发出的thread#run)终止睡眠的话,将一直sleep下去,
9U!c|qq&\.s0返回值是实际睡眠的秒数(整数)。51Testing软件测试网u.f^)uMqJC
51Testing软件测试网_LB&]`+x
同wait比较:
,yL `l(F2Mjz0wait:51Testing软件测试网)V)DZY"`$}
wait是watir中IE类中封装好的函数,Watir API Reference中这样解释它:51Testing软件测试网0c5n+Y#SK%OE
Block execution until the page has loaded ,51Testing软件测试网[S-N7rP
翻译成中文就是:直到页面加载完成才向下执行;51Testing软件测试网.XJ:] |+^L%m0`
51Testing软件测试网S[BG1Io#OWi-c5L51Testing软件测试网!fvvsL51Testing软件测试网Q7pwY;g
`V4M"@Ci&u051Testing软件测试网p%@|5`foD9Q8VMGN _051Testing软件测试网2{wVS*Kv$|51Testing软件测试网]T0NQ6z$EQEa6@
收藏
举报
TAG: