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

每日随笔
  • 每日随笔:

v#jV1os-Ur1eSQ @*P0针对该类对话框的处理方式:51Testing软件测试网*^}+cC.L5XAE$M
require 'watir'
5x,^/s W7[9K n0require 'win32ole'51Testing软件测试网)i(EK1g B]o
require 'watir/WindowHelper'51Testing软件测试网kk/\~-jM
# 登陆
2{ v/q y8StM0$ie_site ='http://members.shaw.ca/paul_rogers/watir_tests/popups1.html'51Testing软件测试网n[+Z.Lb5g
#$f = 'E:\WorkSpace\00-Automation\03_MOA\02_Branches\JiangXi\V2.9.1\Lib\db1.vbs'
u8l0I7rm,q0$ie = Watir::IE.new
Q+Mj eiI `;O0$ie.goto $ie_site51Testing软件测试网\M{ H&xBV3j1@ h

'b3z o??#Y0#遍历所有的按钮控件
+jZq1|6YZQG0#$ie.buttons.each {|b| puts b.to_s}
!BER P@v V` J0
9r,^"h2keG0$ie.button(:value,"Confirm").click_no_wait
t2V4S_)njx0sleep(7)51Testing软件测试网+} uim(gTU%Y7~p,q@G
autoit = WIN32OLE.new("autoitx3.control")
8JVI$L)L{6z,q2K0$a = autoit.WinWait("Microsoft Internet Explorer","",1)
*?0Y2_(IaH3I@0puts $a51Testing软件测试网X nO/Bb&k
$c = autoit.ControlClick("Microsoft Internet Explorer","确定","Button1")
|fz1~)F"U0puts $c
]M4? cL051Testing软件测试网9il:Z*_%[/E8~)K!m/c)~
$a $c 全部为1 说明结果通过。
X `E*G5D`m_y0#相关函数用法:
.`RkcK*R051Testing软件测试网S-_3\\}y5_
=begin51Testing软件测试网k;yD4~/]
defclick_no_wait
8|X V \Rt7a!n0
\%N Ca x2] S(T)SlV0assert_enabled51Testing软件测试网"[$l7W}(t;k
highlight(:set)
pq qAnAk0object="#{self.class}.new(self, :unique_number, #{self.unique_number})"
WB3Ap$h~ L3c0@page_container.eval_in_spawned_process(object+".click!")
3m$?4ia!`BUQ0highlight(:clear)
R;z(]xpR.C051Testing软件测试网f2c [Ky i0RB
end51Testing软件测试网/r6W k'y&@ ]4s U
51Testing软件测试网"g]o6`T4k.W
=end
V.TA:@ Tkn0
+])`Iwcc*pG$S0sleep:51Testing软件测试网GT J+W4S3@+]
51Testing软件测试网 U\(Fv*~y0J
sleep是ruby中自带的函数,它的使用方法是sleep([sec]),意思是:使程序暂停sec秒,省略sec时,51Testing软件测试网[ lH)M#t#C*R T
若没有显示地(sigalrm或其他线程发出的thread#run)终止睡眠的话,将一直sleep下去,51Testing软件测试网-\H*c%Ko2L w
返回值是实际睡眠的秒数(整数)。
lOZ!GJH6m o051Testing软件测试网:a&_h:Z)Z#d
同wait比较:51Testing软件测试网.g2f,P+eh)WN2hp6i&C
wait:51Testing软件测试网,H*L)@q,_Q5{5i0t
wait是watir中IE类中封装好的函数,Watir API Reference中这样解释它:51Testing软件测试网6~ucJ$lM[k"M
Block execution until the page has loaded ,
"ln,g!g YIt0翻译成中文就是:直到页面加载完成才向下执行;
d4_#hH ?z0
51Testing软件测试网 jg^x/B(T%{

f U2\ ]!`v Y0
$htiOrN+o051Testing软件测试网 @vh1@*zx o
51Testing软件测试网?({ e(dH+eG

b?z[-c,s Y,R0
)`n \w8CAA6],u0
9~A.G4B.bPH,G0

TAG:

 

评分:0

我来说两句

Open Toolbar