摘要:
如果使用Ruby脚本,uniq函数就能搞定一切。不过我们现在还是讨论怎么用excel的Countif函数吧。假设Excel中有一列数据:我现在想把重复的数据只留下一个,该如何处理?方法如下:1. 使用Countif函数,计算A列中各个数字重复次数,每次计算的行号是递增的2. 对Excel中所有列进行降序排列,得到如下图:3. 把B列所有大于1的行全部删除即可。 阅读全文
posted @ 2013-08-16 17:10
chenpassion
阅读(3957)
评论(0)
推荐(0)
摘要:
假设Excel中有两列,现在要比较两列数据的不同。我们可以使用Match函数(最后一个参数是0)或者VLookup函数来操作, C列中,#N/A标示,B列中没有A列中的数值。VLookup方法: 阅读全文
posted @ 2013-08-16 17:06
chenpassion
阅读(2383)
评论(0)
推荐(0)
摘要:
require 'win32ole'ai = WIN32OLE.new("AutoItX3.Control")ai.RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255") 阅读全文
posted @ 2013-08-16 17:02
chenpassion
阅读(384)
评论(0)
推荐(0)
摘要:
假设我书写了很多测试用例,测试用例中都有: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 阅读全文
posted @ 2013-08-16 17:01
chenpassion
阅读(313)
评论(0)
推荐(0)
摘要:
如果存在以下的场景:1. 放置在公司的读报机服务器,每天都是开启的;2. 读报机每天下载报纸,一旦成功/失败,就会有相应的记录生成在某个xml文件中;3. 现在有过去一年的读报机下载xml,大约有200多份,每份xml中存储了记录如下:现在你的经理想从测试人员你那儿获取一些知识:过去一年,我们的读报机功能,哪些报纸一直能够给客户下载?哪些报纸我们告诉客户是可以下载的,但是实际上是下载失败的?如果去找开发,也许通过连接数据库,运行一下SQL查询,记录就出来了,但是如果服务器不允许你访问,需要你统计结果,那怎么办?如果你会Ruby脚本,一切都非常简单:path = "C:\\Users\ 阅读全文
posted @ 2013-08-16 17:00
chenpassion
阅读(415)
评论(0)
推荐(0)
摘要:
Similar Threads1. WIN32OLE - failed to create WIN32OLE2. WIN32OLE#[] and WIN32OLE#[]= method in Ruby 1.9 (or later)For example, excel = WIN32OLE.excel("Excel.Application") excel["Visible"] = trueis NG.Instead, You must write excel = WIN32OLE.excel("Excel.Application") e 阅读全文
posted @ 2013-08-16 16:57
chenpassion
阅读(391)
评论(0)
推荐(0)
摘要:
如果安装了搜狗,Watir::Browser.new并不一定能打开新的IE浏览器。这种情况下,必须卸载搜狗浏览器,当然,attach,find方法还是可以用的 阅读全文
posted @ 2013-08-16 16:55
chenpassion
阅读(198)
评论(0)
推荐(0)
摘要:
Watir-WebDriver对于已经打开的浏览器,没有办法进行Attach操作。但是对于自动化操作浏览器过程中点击某链接,打开的新浏览器,是能够定位到的。require 'watir-webdriver'def attach_browser(browser, how, url) browser.driver.switch_to.window(browser.driver.window_handles[0]) browser.window(how, /#{url}/).useendie2 = Watir::Browser.new :chromeie2.goto("ht 阅读全文
posted @ 2013-08-16 16:53
chenpassion
阅读(648)
评论(0)
推荐(0)
摘要:
#Suppose we will access an SVN netrequire 'watir-webdriver'b = Watir::Browser.new :chromeb.goto 'https://admin:password@yourwebsite.com'#Firefox Deal with Certification:profile = Selenium::WebDriver::Firefox::Profile.new profile.assume_untrusted_certificate_issuer = falseb = Watir::B 阅读全文
posted @ 2013-08-16 16:51
chenpassion
阅读(274)
评论(0)
推荐(0)
摘要:
Watir对富文本编辑,一般可以采用b.frame().document.body.innerText = "Value you want to insert"但是Watir-WebDriver不支持这种方法。不过有两种方法可以通过Watir-WebDriver向所见即所得编辑器(应该指的是富文本编辑器)中输入文字:定位编辑器所在的iFrame,然后使用.send_keys方法(缺点是浏览器必须在前台运行)在浏览器上执行javascript,通过js脚本去设置编辑器的值。#CKEditorrequire 'watir-webdriver'b = Watir: 阅读全文
posted @ 2013-08-16 16:50
chenpassion
阅读(439)
评论(0)
推荐(0)
摘要:
以下代码支持Firefox,IE,Chromerequire 'watir-webdriver'#require "watir-webdriver/extensions/alerts"b = Watir::Browser.new :chromeb.goto("http://192.168.10.110:ab/PersonInfo.aspx")b.text_field(:id, "txtName").set("w3")b.text_field(:id, "txtPwd").set( 阅读全文
posted @ 2013-08-16 16:49
chenpassion
阅读(373)
评论(0)
推荐(0)
摘要:
特别声明:该报表框架不是我搭建的。 阅读全文
posted @ 2013-08-16 16:47
chenpassion
阅读(173)
评论(0)
推荐(0)
摘要:
阅读全文
posted @ 2013-08-16 16:46
chenpassion
阅读(178)
评论(0)
推荐(0)
摘要:
我在群空间,总是看到很多Watir新手,反复的问:我对元素的定位怎么又出错?我该从哪里着手啊?我给一个我认为最简单方便的学习方法。1. Ruby语法基础要入门,网上有一个不到2M的帮助文档,从头到尾仔细瞅瞅,每个语句自己手动执行一下,Ruby就能入门了;2. 进入安装好的Ruby,Watir的目录:D:\Ruby193\lib\ruby\gems\1.9.1\gems\watir-classic-3.0.0,把该文件夹导出到eclipse或者Netbeans项目中,就这些Example一个个执行下去,之后基本上就是Watir入门了。 阅读全文
posted @ 2013-08-16 16:42
chenpassion
阅读(214)
评论(0)
推荐(0)
摘要:
以下是一个很经典的把Watir与AutoIt连接在一起的实例。如果我们对AutoIT了解的更多,处理类似的问题会更加简单。以下实例会判断页面上是否有某“删除”链接,一旦有该链接,就点击,然后点击弹出的警告框上的“确定”按钮,直到页面上不再有“删除”链接为止。require 'watir'require 'win32ole'class WindowHelper def initialize( ) @autoit = WIN32OLE.new('AutoItX3.Control') end def push_alert_button() @autoi 阅读全文
posted @ 2013-08-16 16:41
chenpassion
阅读(534)
评论(0)
推荐(0)
摘要:
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 阅读全文
posted @ 2013-08-16 16:39
chenpassion
阅读(376)
评论(0)
推荐(0)
摘要:
对于Ruby 1.8版本,以管理员身份运行命令行窗口,输入Regsvr32 AutoItX3.dll路径即可。对于1.9 版本,路径与1.8版本是不同的,我们可以进入Ruby安装目录下,搜索AutoItX3.dll,搜索到之后,找到相应路径,然后以管理员身份运行命令行窗口,输入:regsvr32 D:\Ruby193\lib\ruby\gems\1.9.1\gems\rautomation-0.7.2\ext\AutoItX\AutoItX3.dll回车即可。 阅读全文
posted @ 2013-08-16 16:38
chenpassion
阅读(625)
评论(0)
推荐(0)
摘要:
为了提高自己的工作效率,我曾经对Watir进行了系统性的学习,比起学习C++,Java等始终不得门,Watir还是学进去了,能够完整搭建出一个自己很容易理解的自动化架构。之后我想继续在自动化测试方明提高自己,就把Ruby语言从头到尾走了一遍,还是有些收获的,虽然现在脑海里面也记不起来多少东西,但是就自动化测试这一方面来说,还是很有自信的。Watir,Ruby能够很大程度上提高测试效率,这点是毋庸置疑的,印象深刻的是,以下场景下,Watir和Ruby帮了我的忙。场景1:重现一些难以重现的Bug公司产品有一个功能,用户可以在google地图上画一条路线,然后可以在这条路线上跑步健身,从而进行一些统 阅读全文
posted @ 2013-08-16 16:36
chenpassion
阅读(358)
评论(0)
推荐(0)
摘要:
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 阅读全文
posted @ 2013-08-16 16:34
chenpassion
阅读(357)
评论(0)
推荐(0)
摘要:
b =Watir::IE.newb.goto'http://www.google.com/'txt =b.element_by_xpath("//*[@name='q']")txt.value= 'Richard Lawrence'btn =b.element_by_xpath("//*[@name='btnG']")btn.click@b.elements_by_xpath("//div[@class='UserServiceValues']").eac 阅读全文
posted @ 2013-08-16 16:32
chenpassion
阅读(472)
评论(0)
推荐(0)
摘要:
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 阅读全文
posted @ 2013-08-16 16:29
chenpassion
阅读(347)
评论(0)
推荐(0)
摘要:
def save_file(filepath) ai =WIN32OLE.new("AutoItX3.Control") ai.WinWait("FileDownload", "", 2) ai.ControlFocus("FileDownload", "", "&Save") sleep 1 ai.ControlClick("FileDownload", "", "&Save", "lef 阅读全文
posted @ 2013-08-16 16:27
chenpassion
阅读(296)
评论(0)
推荐(0)
摘要:
require 'watir'module Watir class Element def top_edge assert_exists assert_enabled ole_object.getBoundingClientRect.top.to_i end def top_edge_absolute top_edge + page_container.document.parentWindow.screenTop.to_i end def left... 阅读全文
posted @ 2013-08-16 16:26
chenpassion
阅读(552)
评论(0)
推荐(0)
摘要:
ie.#{element}(:id,"foo").document.currentstyle.attributeAsCamelCasesoie.#{element}(:id,"foo").document.currentstyle.fontFamilyie.#{element}(:id,"foo").document.currentstyle.fontSizeie.#{element}(:id,"foo").document.currentstyle.colorSometimesyou have to use in 阅读全文
posted @ 2013-08-16 16:22
chenpassion
阅读(300)
评论(0)
推荐(0)
摘要:
$!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 阅读全文
posted @ 2013-08-16 16:19
chenpassion
阅读(342)
评论(0)
推荐(0)
摘要:
1). buttons Xpath1)Button propertiesbrowser.button(:xpath,"//input[@id='b2']/").namebrowser.button(:xpath,"//input[@id='b2']/").idbrowser.button(:xpath,"//input[@id='b2']/").type2)browser.button(:xpath,"//input[@value='Click Me']/&qu 阅读全文
posted @ 2013-08-16 16:17
chenpassion
阅读(297)
评论(0)
推荐(0)
摘要:
可以应用AutoIT开发出界面,从而把AutoIT对GUI的自动化测试与Watir对web的自动化测结合在一起。以下代码是我学习GUI界面开发的实例代码。1. 当点击Watir_Test_Button,就会打开IE 浏览器,到达百度页面;2. 当点击GUI_Automation_Test,就会打开notepad,并在其中输入一些文字。#include #include #include #include #include #include #include ; Window, Pic, Label, Lable background colorGUICreate("Sample GU 阅读全文
posted @ 2013-08-16 16:14
chenpassion
阅读(2405)
评论(0)
推荐(0)
摘要:
以前用Ruby脚本,对于中文,数字结合的文件名,修改名字也不是非常简单,需要修改字符集,可是用autoit来实现,也挺简单的,并且可以替换已有文件名中的汉字部分。$filepath = "Filewith\2000.7月底延期事宜"if FileExists($filepath) Then FileChangeDir($filepath) $search = FileFindFirstFile("*.*") ; 检查搜索是否成功 If $search = -1 Then ConsoleWrite("No file") Exit End 阅读全文
posted @ 2013-08-16 16:12
chenpassion
阅读(1337)
评论(0)
推荐(0)
摘要:
GUICtrlCreateCombo中选中的选项是可修改的,也可设置为不可修改状态。#includeGUICtrlCreateLabel("ComboTest: ", 180, 280, 120, 20)GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT); Combo 选中的选项是可修改的状态GUICtrlCreateCombo("",250, 277, 120, 100); Combo 选中的选项是不可修改的状态,最后一个参数也可只为:$CBS_DROPDOWNLISTGUICtrlCreateCombo(&q 阅读全文
posted @ 2013-08-16 16:08
chenpassion
阅读(854)
评论(0)
推荐(0)
摘要:
GUISetFont 可以设置默认字体,后面的资源都会用该字体,而 GUICtrlSetFont 可以对特定控件的字体进行设置。;Combo,setfont, GUICtrlSetFont$font= "Comic Sans MS"$fontlabel= GUICtrlCreateLabel("Combo Test: ", 160, 280, 120, 20)GUICtrlSetFont($fontlabel,10,20, 2, $FONT)GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)$comboFont= 阅读全文
posted @ 2013-08-16 16:07
chenpassion
阅读(842)
评论(0)
推荐(0)
摘要:
#include $excel = _ExcelBookAttach("Book1.xlsx" ,"FileName")Dim $i = 1;_ExcelReadCell($excel,"b"&$i) "" 并不等于 not(_ExcelReadCell($excel,"b"&$i) ==""),使用的时候尽量使用后者While IsInt(_ExcelReadCell($excel,"b"&$i)) $ten = _ExcelRe 阅读全文
posted @ 2013-08-16 16:06
chenpassion
阅读(3122)
评论(0)
推荐(0)
摘要:
#include$conn= ObjCreate("ADODB.Connection")$RS= ObjCreate("ADODB.Recordset")$conn.Open("driver={SQLServer};server=a\demo;uid=sa;pwd=bcd;database=Test")$RS.ActiveConnection= $conn$RS.open("SELECT* FROM GIS_CROP");以下代码可以获取数据库表的标题名;$count = $RS.Fields.Count;dim 阅读全文
posted @ 2013-08-16 16:03
chenpassion
阅读(2570)
评论(1)
推荐(0)
摘要:
_filelist("D:\Snagit 10")Func _filelist($searchdir) ;;;函数名(形参) $search = FileFindFirstFile($searchdir & "\*.*") ;;;;查找c:根目下的文件 If $search = -1 Then return -1 ;;;;如果找不到,返回值 -1 While 1 $file = FileFindNextFile($search) ;;;查找下一个文件 If @error Then ... 阅读全文
posted @ 2013-08-16 16:01
chenpassion
阅读(1759)
评论(0)
推荐(0)
摘要:
Func down() $Size=InetGetSize($a[$j][1]);获得FTP上的文件的大小 InetGet($a[$j][1],$a[$j][2],1,1);下载 ProgressOn("下载进度表", "正在下载 ..."& StringRight($a[$j][1],20),"0 %") While @InetGetActive $i=round(@InetGetBytesRead / $Size * 100) ProgressSet( $i, $i & " %") ;TrayT 阅读全文
posted @ 2013-08-16 16:00
chenpassion
阅读(988)
评论(0)
推荐(0)
摘要:
一般情况下,GridView中的数据来自数据库,我们通过Windows Info,是无法获取GridView中的信息的。而软件定制的Menu,很多时候无法通过系统提供的WinMenuSelectItem来获取。对于GridView窗口或者WinMenuSelectItem窗口等等,如果无法通过常规手段获取的资源,都可以使用ControlClick和ControlSetText命令对字段进行点击/双击/赋值操作。;Get the handle of the main window$handle = WinGetHandle("[class:WindowsForms10.Window.2 阅读全文
posted @ 2013-08-16 15:59
chenpassion
阅读(3719)
评论(1)
推荐(0)
摘要:
WinGetText是一个非常有用的函数,可以获取页面上一切可见的资源,这为自动化测试的验证功能提供了保证。可以使用一些字符串处理函数来对获取来的页面文本进行分析。If StringInStr(WinGetText($handle),"Trial_Days") Then MsgBox(0,"Test", "String is set successfully")Else MsgBox(0,"Test2", "No value")EndIfMsgBox(0,"Test3", W 阅读全文
posted @ 2013-08-16 15:57
chenpassion
阅读(1741)
评论(0)
推荐(0)
摘要:
一般情况下,Gridview是无法通过AutoIT Window Info来获取控件信息的,但是可以有折中的办法对Gridview中的字段赋值。#include$handle= WinGetHandle("[Handle:0x0000000000260D3E]") ;MsgBox(0,"Test", $handle);WinActivate($handle);ControlClick($handle,"","WindowsForms10.Window.8.app.0.1f550a4_r15_ad129"," 阅读全文
posted @ 2013-08-16 15:55
chenpassion
阅读(954)
评论(0)
推荐(0)
摘要:
$url2 = "AX.XXX.XXX.COM"$oIE = _IECreate ($url2, 0, 1, 0, 1)Sleep(1000)ControlSetText('[REGEXPTITLE:连接到.+]', '', 1003, 'username')ControlSetText('[REGEXPTITLE:连接到.+]', '', 1005, 'password')ControlClick('[REGEXPTITLE:连接到.+]', '' 阅读全文
posted @ 2013-08-16 15:51
chenpassion
阅读(494)
评论(0)
推荐(0)
摘要:
#include$handle =WinGetHandle("Windows 任务管理器");$ctrl =ControlGetHandle($handle,"","SysListView321")dim $count =ControlListView($handle,"","SysListView321","GetItemCount")MsgBox(0,"Test",$count)dim $idim $array1[2] = [0, 4]dim $arr 阅读全文
posted @ 2013-08-16 15:50
chenpassion
阅读(839)
评论(0)
推荐(0)
摘要:
$handle= WinGetHandle("Sample GUI");MsgBox(0,"SRE Example 3 Result", $handle)$ctrl= ControlGetHandle($handle, "", "Static1");MsgBox(0,"SRE Example 3 Result", $ctrl)$a1= ControlGetHandle($handle, "", "msctls_progress321");MsgBox(0, 阅读全文
posted @ 2013-08-16 15:48
chenpassion
阅读(1128)
评论(0)
推荐(0)
摘要:
$fHandle= FileOpen("文件", 0)if $fHandle -1 Then While 1 $line= FileReadLine($fHandle) If@error = -1 Then ExitLoop WendEndIfFileClose($fHandle) 阅读全文
posted @ 2013-08-16 15:40
chenpassion
阅读(1363)
评论(0)
推荐(0)
摘要:
ControlCommand可以确定窗口中的复选框是否选中状态,然后可以对这些复选框进行操作。可以对ComboBox和ListBox进行操作如选择下拉框的某个选项if WinExists("AutoIt 帮助") Then MsgBox(1,"OK", "Start") WinActivate("AutoIt帮助") if ControlCommand("AutoIt 帮助","","Button5","IsChecked", &quo 阅读全文
posted @ 2013-08-16 15:39
chenpassion
阅读(5557)
评论(0)
推荐(0)
摘要:
对文件系统的菜单进行操作,有专门的语句WinMenuSelectItem:Run("notepad.exe")WinWaitActive("[CLASS:Notepad]")WinMenuSelectItem("[CLASS:Notepad]","", "文件(&F)", "页面设置(&U)..." )WinMenuSelectItem 有很强的局限性,很多定制的Menu无法操作。以后出现了新的Menu,一旦能够操作,将把代码拷贝到当前页面。 阅读全文
posted @ 2013-08-16 15:35
chenpassion
阅读(2499)
评论(0)
推荐(0)
摘要:
句柄是独一无二的,很多时候,Title,Command都可以用句柄来代替。以下写法是能够起一样的作用。$handle= WinGetHandle("autoit cn")$ctrl= ControlGetHandle("autoit cn","","[CLASS:Button;INSTANCE:5]")ControlClick($handle,"",$ctrl);controlclick("autoitcn", "", "[CLASS:Butto 阅读全文
posted @ 2013-08-16 15:34
chenpassion
阅读(1237)
评论(0)
推荐(0)
摘要:
$handle= WinGetHandle("Program Manager")$ctrl= ControlGetHandle("ProgramManager","","[CLASS:SysListView32; INSTANCE:1]") $pos= WinGetPos ($handle)MsgBox(0,"DesktopWidth","Desktopwidth: " & $pos[2] & @CRLF & "Desktop height: 阅读全文
posted @ 2013-08-16 15:33
chenpassion
阅读(1724)
评论(0)
推荐(0)
摘要:
Example()FuncExample() ; Run Notepad Run("notepad.exe") ; Wait 10 seconds for the Notepad window toappear. Local $hWnd =WinWait("[CLASS:Notepad]", "", 10) MsgBox(1,"Test1", $hWnd, 3) ; Convert the handle to a string. Local $sHWnd = String($hWnd) MsgBox(1," 阅读全文
posted @ 2013-08-16 15:29
chenpassion
阅读(2469)
评论(0)
推荐(0)
摘要:
If WinExists("[CLASS:Notepad2]") Then Local $hWnd = WinWait("[CLASS:Notepad]", "",10) ; Convert the handle to a string. Local $sHWnd = String($hWnd) WinActivate("[CLASS:Notepad]") ;WinWaitActive("[class:Notepad]") Send("Hello")EndIf 阅读全文
posted @ 2013-08-16 15:27
chenpassion
阅读(2336)
评论(0)
推荐(0)
摘要:
1. ControlSetText :可以摆脱Send的限制,在适当的文本框位置输入用户想要输入的信息。2. ControlGetText可以获取文本Run("notepad.exe")WinWait("[CLASS:Notepad]") ControlSetText("[CLASS:Notepad]", "", 15,"New Text Here")Local $sText = ControlGetText("[CLASS:Notepad]","", 1 阅读全文
posted @ 2013-08-16 15:19
chenpassion
阅读(2480)
评论(0)
推荐(0)
浙公网安备 33010602011771号