zoukankan      html  css  js  c++  java
  • Watir Popup 采用新线程进行处理

    require 'watir'
     require 'win32ole'
    $h"A I o T9~o#n*X*~0def check_for_popups(title="Microsoft Internet Explorer", button="OK")51Testing软件测试网0T o A-F e w8q ?
        popup=Thread.new{
    &g7U(j9J,W y0        autoit=WIN32OLE.new('AutoItX3.Control')51Testing软件测试网(d q"k1o;^)p8R
            ret=autoit.WinWait(title,"",60)
    qt.`$o R.o x p D v0       if(ret==1)
    u C5d,\6~,r"|$j0            puts"There is popup."
    3t u L.U Q I.[5l B q0            autoit.WinActivate(title)51Testing软件测试网 w T4x J j t ? v
                button.downcase!51Testing软件测试网 j y l t Y _ g+O
               ifbutton.eql?("ok") || button.eql?("yes") || button.eql?("continue")
    K%K f%D-| \ } L:V!}6J R0                autoit.Send("{Enter}")51Testing软件测试网 U2`7Z i F@
               else51Testing软件测试网 [ Y k z J'i @ D%P
                    autoit.Send("{tab}")
    5j X9m y l L2U T0                autoit.Send("{Enter}")51Testing软件测试网 p)~8N5t6l&m5@
                end
    ;J+H x+R S$j"g:\G0        elsif (ret==0)
    (Q H d/F)N \/J9Z Q I J P0            puts"No popup, please check your code."
    Q w%F S+Q K)j0        end
    (h d!m N C0    }
    )W9| V } J1h k6f0    at_exit {Thread.kill(popup) }
    7o j So!G0end51Testing软件测试网3i ~ n E)P
    51Testing软件测试网 C N!D/z.V l'i,O
    $ie.link(:text,//).click_no_wait51Testing软件测试网.s V+V [ j.a k y ] g:z
    check_for_popups("MicrosoftInternet Explorer","OK")51Testing软件测试网"e u3W O F9Y5X/H }
    这个方法针对 Popup是 OK/cancel之类的弹出框比较有效。

  • 相关阅读:
    c++最大公约数
    c++判断一个整数里面是否包含 3 这个数字
    动态使用webservice,以及含有ref类型的参数的问题
    带有用户名密码验证的远程文件下载
    注册表
    fsdfasfsa
    C# addin 开发心得记录
    c# 读写注册表
    like的性能问题
    查找表中多余的重复记录(多个字段)
  • 原文地址:https://www.cnblogs.com/zhangfei/p/2017246.html
Copyright © 2011-2022 走看看