惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
M
MIT News - Artificial intelligence
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
Recent Announcements
Recent Announcements
Stack Overflow Blog
Stack Overflow Blog
人人都是产品经理
人人都是产品经理
IT之家
IT之家
F
Fortinet All Blogs
博客园 - 聂微东
U
Unit 42
Martin Fowler
Martin Fowler
腾讯CDC
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky

博客园 - CrazyCoder

Ubuntu 7.10安装mplayer出现failed to load: drvc.so错误的解决办法 QueryString中的加号不见了 Google Docs Presentation is live now! 你是哪种类型的程序员? 在团队中建立领导能力 国内Ruby On Rails最新动态 framework vs. library learning MVC Top 6 List of Programming Top 10 Lists Reflector 5 Released LINQ/C# Learning Guide - via TheServerSide ProgrammingBooks.org first work day of 2007, first work day in new company 2006年的最后一天,以及2007,我最Google的期望 一些安装VS2005 SP1的技巧 下一版VS.NET的一些新功能 [读书笔记]软件开发中,人和过程的关系 Windows Vista SDK released ideaWins,微软推出了免费的Office Accounting 2007 Express
handling popup window in Watir
CrazyCoder · 2007-04-17 · via 博客园 - CrazyCoder

Handling popup window in testing browser based applications is always an annoying problem. Watir provides a good solution for this, here is what I learned from the Watir mail list and share it here to everyone else.

You will need newest Watir (build late than 1.5.1.1079) to do it.

Here is the ruby scripts to handle popup windows:  

#includes
require 'watir'   # the controller
require 'watir\contrib\enabled_popup'
include Watir

#test::unit includes
require 'test/unit'

class TC_dimensionnet_login < Test::Unit::TestCase

  def test_window_popup
 
    testSite = "http://localhost/test.htm"
   
    $ie = Watir::IE.new
   
    $ie.goto(testSite)
   
    $ie.button(:id,"btnPopup").click
    startClicker("OK", 5)
  end
 
  # function click buttons on a popup window
  def startClicker( button , waitTime=9, user_input=nil )

     hwnd = $ie.enabled_popup(waitTime)  # get a handle if one exists
    
     if (hwnd)  # yes there is a popup
     puts hwnd
       w = WinClicker.new

       if ( user_input )
         w.setTextValueForFileNameField( hwnd, "#{user_input}" )
       end

       sleep 3  # I put this in to see the text being input it is not necessary to work
       w.clickWindowsButton_hwnd( hwnd, "#{button}" )  # "OK" or whatever the name on the button is
       w=nil    # this is just cleanup

     end

   end
  
end


Powered by ScribeFire.