不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。                                           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

每日随笔
  • 每日随笔:

Z%e2|uc0针对该类对话框的处理方式:51Testing软件测试网rW,u ]\ e
require 'watir'
K lo,aPnm/i0require 'win32ole'51Testing软件测试网 O@8F3]3fX k
require 'watir/WindowHelper'51Testing软件测试网.gr C ^^P&|
# 登陆51Testing软件测试网-nF@_ ug
$ie_site ='http://members.shaw.ca/paul_rogers/watir_tests/popups1.html'51Testing软件测试网lDiq-@,e'[o&e
#$f = 'E:\WorkSpace\00-Automation\03_MOA\02_Branches\JiangXi\V2.9.1\Lib\db1.vbs'51Testing软件测试网F8q'pC+T)p#h3Q
$ie = Watir::IE.new
~2^,a/B/K;aW~0$ie.goto $ie_site51Testing软件测试网P'YX&x:B)d

&y;N+[&aF}H0#遍历所有的按钮控件51Testing软件测试网a)jdZZ5a
#$ie.buttons.each {|b| puts b.to_s}
'aB$gXD sb051Testing软件测试网*qe/VMi T,Dn D'M
$ie.button(:value,"Confirm").click_no_wait51Testing软件测试网~wPC(]-`5dj
sleep(7)
f4bwqkH*g ] U0autoit = WIN32OLE.new("autoitx3.control")51Testing软件测试网^^ NV4t
$a = autoit.WinWait("Microsoft Internet Explorer","",1)
?L$A\ Or0puts $a
#J$^.u9qO#l0$c = autoit.ControlClick("Microsoft Internet Explorer","确定","Button1")51Testing软件测试网'a$k?(qU1]@
puts $c51Testing软件测试网9Pc7I9Z"s&I'q_

t&Yd%T*CF8B0$a $c 全部为1 说明结果通过。51Testing软件测试网G!uK5\LC
#相关函数用法:
g5BRf| fGOW\)?(K051Testing软件测试网z\V.ji.k+V"~2RY(C-z
=begin
aJ d&gA}%G)h0
defclick_no_wait
2I;@Q1K*gh"s:Fq0d0
4^c*]4M1h n0assert_enabled51Testing软件测试网(ZQ.\n!s
highlight(:set)
/mn]!Ha7IpsJ0object="#{self.class}.new(self, :unique_number, #{self.unique_number})"51Testing软件测试网7YD.HG E'`
@page_container.eval_in_spawned_process(object+".click!")51Testing软件测试网 |)zEk)Y0c
highlight(:clear)51Testing软件测试网\$H"Z-f6_P_)WA

4u| U2q2UT|6Ti0end
o)\u[s r0
M+}e4\$H%]YJ0=end
X4TYus d"LdCi051Testing软件测试网S(R AVq7Q1q2j)?
sleep:
3K@6}/I']te:ic0
&`^H\8R@F0
sleep是ruby中自带的函数,它的使用方法是sleep([sec]),意思是:使程序暂停sec秒,省略sec时,
KX/Z y,B|/\0若没有显示地(sigalrm或其他线程发出的thread#run)终止睡眠的话,将一直sleep下去,
]ckO Q#\.QVN.q6|0返回值是实际睡眠的秒数(整数)。51Testing软件测试网#k,b7lF)u)o X

^| S0N/aM8C0同wait比较:51Testing软件测试网U8A uw(d`-ON A
wait:51Testing软件测试网[ [7T-q Zo9M
wait是watir中IE类中封装好的函数,Watir API Reference中这样解释它:51Testing软件测试网B7iWcRz6a
Block execution until the page has loaded ,51Testing软件测试网 V,C!hIpTn
翻译成中文就是:直到页面加载完成才向下执行;51Testing软件测试网xU,qj3Et~xe

3{2q'O X$b051Testing软件测试网K6APZT+h$V2c#M
51Testing软件测试网@A%B3K#a'e
51Testing软件测试网Yf8c/u(V6Y0I\
51Testing软件测试网b)E]C+pQ%EM;u

5w1o*k)qZk8mo0OXxr051Testing软件测试网7y2}NI y"P
51Testing软件测试网&gj4y B^b

TAG:

 

评分:0

我来说两句

Open Toolbar