摘要: 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 阅读(349) 评论(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 阅读(462) 评论(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 阅读(335) 评论(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 阅读(283) 评论(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 阅读(536) 评论(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 阅读(289) 评论(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 阅读(334) 评论(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 阅读(290) 评论(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 阅读(2335) 评论(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 阅读(1272) 评论(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 阅读(833) 评论(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 阅读(819) 评论(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 阅读(3014) 评论(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 阅读(2476) 评论(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 阅读(1641) 评论(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 阅读(908) 评论(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 阅读(3618) 评论(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 阅读(1693) 评论(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 阅读(928) 评论(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 阅读(485) 评论(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 阅读(811) 评论(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 阅读(1052) 评论(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 阅读(1325) 评论(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 阅读(5288) 评论(0) 推荐(0) 编辑
摘要: 对文件系统的菜单进行操作,有专门的语句WinMenuSelectItem:Run("notepad.exe")WinWaitActive("[CLASS:Notepad]")WinMenuSelectItem("[CLASS:Notepad]","", "文件(&F)", "页面设置(&U)..." )WinMenuSelectItem 有很强的局限性,很多定制的Menu无法操作。以后出现了新的Menu,一旦能够操作,将把代码拷贝到当前页面。 阅读全文
posted @ 2013-08-16 15:35 chenpassion 阅读(2423) 评论(0) 推荐(0) 编辑