`
candyania
  • 浏览: 33725 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论
文章列表
  public class MyTest extends TestCase { private int count = 0; public void test1() { count++; assertEquals(1, count); } public void test2() { count++; assertEquals(1, count); } }  Take a quick look at this test case and imagine running it with JUnit. What do you think will happen? ...
转自: http://hi.baidu.com/xiaoxiaolq/blog/item/66c78d16a64d295bf2de32fa.html 在java中,异常的捕捉是在try ... catch当中进行,而ruby则是在begin ... end代码块中进行异常的捕捉,在该代码块中使用rescue关键字进行捕捉异常类型,注意哦,这个是关键字,而不是方法。 Ruby代码 begin ...... #可能出现异常的代码 rescue errorType1 #要捕捉的异常 ...
#open the IE browser ie = Watir::IE.new # go to login site ie.goto test_site ie.show_frames ie.frame(:id, "leftFrame").link(:id,"divDB").click ie.frame(:id, "mainFrame").text_field(:id, "PoolName2").set(poolname)# "USER" is name of usernam ...
################################################### #Main Application Code Start ################################################### puts "---begin---" #display msgbox to ask user to input from keyboard MessageBox = Win32::API.new("MessageBox", 'LPPI', 'I', "user3 ...
require 'win32ole' def set_up @au3 = WIN32OLE.new "AutoItX3.Control" @au3.opt "WinTextMatchMode", 2 end def browse_to url @au3.Run "C:\\Program Files\\Mozilla Firefox2\\firefox.exe #{url}" end def enter @au3.Send "{ENTER}" end def tab sen ...
Send 向激活窗口发送模拟键击操作。 Send ( "按键" [, 标志] )   参数 按键 要发送的按键序列。 标志 [可选参数] 更改程序处理“按键”的方式:  标志 = 0 (默认),按键序列中含有的特殊字符比如 + 和 ! 将被视为 SHIFT 和 ALT 键。  标志 = 1,按键将按原样发送。   返回值 无
从http://rdoc.info/projects/hpricot/hpricot 转来的关于如何使用Hpricot的rdoc以及example. 等有空的时候把它翻译成中文。Hpricot, Read Any HTML Hpricot is a fast, flexible HTML parser written in C. It's designed to be very accommodating (like Tanaka Akira's HTree) and to have a very helpful library (like some JavaScript libs -- JQ ...
require 'windows/system_info' require 'singleton' require 'thread' require 'watir/cookiemanager' require 'net/http' def soap_call(server, port, url_right_part, input_xml) http = Net::HTTP.new(server, port) resp, return_data = http.post(url_right_part, input_xml, {'SOAPAction' => ...
今天研究了一些Ruby的继承,跟C++等语言有所不同,直接看代码: require 'watir' class TestInherit #Getter attr_reader:a def initialize #this is for all ids initialization @a = "10000000986" end #end of def initialize end #end of class class ChildTest < TestInherit attr_rea ...
Ruby 语言与Python和Perl的一个很大区别,在于Ruby中,所有的实例变量都是在类中完全私有的,只能通过accessor 方法来进行变量访问,引用一段代码来说明具体的使用方法: class Rectangle attr_accessor :width attr_accessor :height attr_accessor :width2 attr_accessor :height2 def initialize(wdth, hgt) @width = wdth @height = hgt end def a ...
先贴个图:   看了javaeye上某一高人关于如何用win32api点击ie提示条的文章,学习了这种方法,不过原文没有进一步说明,当点击提示条出现下拉选项时,应该如何点击相应的选项的方法,我自己用autoit解决了这个问题,代码如下:   先看原文中的windowsAPI module代码如下:   ################################################### #WindowsAPI Module ############################################# module WindowsInput ...
################################################### #Get specific element by traversal the whole page ############################################# def get_element(elem_type,elem_attr,elem_text,ie_n) begin if ie_n==1 #ie main window element if elem_type=~ /checkbox/i ...
# 使用Watir工具,需要在脚本中加上 require 'watir' # 创建一个IE的实例 ie = Watir::IE.new # 或者在创建的同时直接转到页面 ie = Watir::IE.start('http://www.text.com/') # Watir使用start方法同时创建一个浏览器实例并转到一个页面。 # IE浏览速度 ie.speed = :fast ie.speed = :slow # 页面导航 ie.goto('http://www.text.com/') ...
今天发现一个问题:   多次Run脚本之后,$ie = Watir::IE.new突然不能启动浏览器了,也不会报错,就一直死在那里   我清了cookie居然不能解决,重启机器可以解决这个问题,不过这个方法太傻   最后找到了解决方法:   用 $ie = Watir::IE.new_process 代替 $ie = Watir::IE.new   问题就解决了,具体原因不详...还在继续钻研中
最近想用Watir+Ruby写几个简单的脚本来提高工作效率,功能很简单,但是因为页面有多个security popup和弹出子窗口,还是头疼了几天,网上查了很多解决方法,综合总结如下: 1. AutoItX: require 'watir' #require 'win32ole' # already included ...
Global site tag (gtag.js) - Google Analytics