日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

如何安装和使用RAutomation

發布時間:2025/5/22 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何安装和使用RAutomation 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天在本地的gem list中發現了1個叫做rautomation的擴展,仔細一看原來這是個使用watir的語法進行windows程序測試的工具庫,不敢獨享,略志一二。

首先看一下rautomation的簡介

RAutomation is a small and easy to use library for helping out to automate windows and their controls for automated testing. RAutomation是個小巧易用的工具庫,其主要用來進行windows窗體和控件的自動化測試工作。

RAutomation的特點

  • Easy to use and user-friendly API (inspired by Watir http://www.watir.com) 易用的watir like API
  • Cross-platform compatibility 跨平臺
  • Easy extensibility - with small scripting effort it's possible to add support for not yet supported platforms or technologies 易擴展

RAutomation的用法

require "rautomation"# 通過匹配部分標題來獲取窗口 window = RAutomation::Window.new(:title => /part of the title/i) window.exists? # => true window.title # => "blah blah part Of the title blah" window.text # => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultricies..."# 控件操作 window.text_field(:class => "Edit", :index => 0).set "hello, world!" button = window.button(:text => "&Save") button.exists? # => true button.click# 獲取當前所有窗口的句柄 all_windows = RAutomation::Window.windows all_windows.each {|window| puts window.hwnd}# 根據標題匹配所有窗口 window = RAutomation::Window.new(:title => /part of the title/i) windows = window.windows puts windows.size # => 2 windows.map {|window| window.title } # => ["part of the title 1", "part of the title 2"] window.windows(:title => /part of other title/i) # => all windows with matching specified title# 遍歷窗口上所有的button控件 window.buttons.each {|button| puts button.value} window.buttons(:value => /some value/i).each {|button| puts button.value}# 使用autoit adapter來定位和操作窗口 # 注意:需要注冊AutoitX的DLL window2 = RAutomation::Window.new(:title => "Other Title", :adapter => :autoit) # use AutoIt adapter # 使用autoit的原生方法來操作控件 # use adapter's (in this case AutoIt's) internal methods not part of the public API directly window2.WinClose("[TITLE:Other Title]")

RAutomation的安裝

安裝了watir 1.9后該擴展自動安裝。另外也可以使用下面的命令進行安裝

gem install rautomation

總結

以上是生活随笔為你收集整理的如何安装和使用RAutomation的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。