随笔分类 - Ruby
摘要:Watir使用过程中,经常遇到的弹出框分为几类:1. Alert2. Confirm3. Prompt4. File selectWatir 处理弹出框,有很多方法,可以应用 AutoIt来处理,也可以通过 RAutomation来处理。AutoIt的局限性是无法跨平台,所以在Watir 4.0中被...
阅读全文
摘要:RAutomation的用法require "rautomation"# 通过匹配部分标题来获取窗口window = RAutomation::Window.new(:title => /part of the title/i)window.exists? # => truewindow.title...
阅读全文
摘要:require 'nokogiri'XML_FILE = "C:\\Users\\chenpassion\\Desktop\\20130806.xml"xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)xml.xpath('//NewspaperReport').each {|x| if !x.attributes.include?("DownloadState") || x.attributes["DownloadState"].value
阅读全文
摘要:假设我书写了很多测试用例,测试用例中都有:require 'test/unit'后来我想把很多这样的测试用例组织在一起运行,我使用了两个require:require 'test/unit'require 'test/unit/ui/console/testrunner'于是我运行如下用例集合:include Test::Unit::UI::Console testcases = [TC_AddPeople] testcases.each{|testcase| TestRunner.run(testcase)}我得到的错误提示如下:Loaded
阅读全文
摘要:如果存在以下的场景:1. 放置在公司的读报机服务器,每天都是开启的;2. 读报机每天下载报纸,一旦成功/失败,就会有相应的记录生成在某个xml文件中;3. 现在有过去一年的读报机下载xml,大约有200多份,每份xml中存储了记录如下:现在你的经理想从测试人员你那儿获取一些知识:过去一年,我们的读报机功能,哪些报纸一直能够给客户下载?哪些报纸我们告诉客户是可以下载的,但是实际上是下载失败的?如果去找开发,也许通过连接数据库,运行一下SQL查询,记录就出来了,但是如果服务器不允许你访问,需要你统计结果,那怎么办?如果你会Ruby脚本,一切都非常简单:path = "C:\\Users\
阅读全文
摘要:class WIN32OLE def list_ole_methods method_names = ole_methods.collect {|m| m.name} puts method_names.sort.uniq endendWIN32OLE.new('Shell.Application').list_ole_methods得到如下方法:AddRefAddToRecentApplicationBrowseForFolderCanStartStopServiceCascadeWindowsControlPanelItemEjectPCExploreExplorerPol
阅读全文
摘要:1. Kill the taskcmd2="taskkill /F /IM typeperf.exe"stdout2=%x{#{cmd2}}2. Start counters:cmd="typeperf -cfc:\\test.txt>c:\\test3.csv"3. Get system info:require "sys/cpu"include SysCPU.processors{ |cs| cs.members.each{ |m| puts "#{m}: " + cs[m].to_s }}puts &q
阅读全文
摘要:require'win32/registry'hkey_local_machine=Win32::Registry::HKEY_LOCAL_MACHINEdefgetKeyValue(hive, key_path, key_name)reg_obj=hive.open(key_path, Win32::Registry::KEY_READ)beginreg_typ, reg_val = reg_obj.read(key_name)rescue Win32::Registry::Errorputs "key not found : #{key_name}"en
阅读全文
摘要:$!latesterror message$@locationof error$_stringlast read by gets$.linenumber last read by interpreter$&stringlast matched by regexp$~thelast regexp match, as an array of subexpressions$nthenth subexpression in the last match (same as $~[n])$=case-insensitivityflag$/inputrecord separator$\outputr
阅读全文
浙公网安备 33010602011771号