ruby的并发应用
上一篇 /
下一篇 2011-07-11 18:29:06
/ 个人分类:ruby+watir
require 'thread'
require 'watir'
ie = Watir::IE.new()
def test1
#ie=Watir::IE.new
#ie.goto('http://www.baidu.com')
ie = Watir::IE.start('http://www.baidu.com')
ie.text_field(:type, "text").set("pickaxe")
ie.button(:type, "submit").click
#ie.close
end
def test2
#ie=Watir::IE.new
#ie.goto('http://www.baidu.com')
ie = Watir::IE.start('http://www.baidu.com')
ie.text_field(:type, "text").set("mp3")
ie.button(:type, "submit").click
#ie.close
end
def test3
ie= Watir::IE.start('http://www.163.com')
ie.text_field(:type, "text").set("800716@163.com")
ie.text_field(:type, "password").set("841224")
ie.button(:type, "submit").click
# run the same
test three times concurrently in separate browsers
end
threads = []
runs=[]
#2.times do
threads << Thread.new {test1}
threads << Thread.new {test2}
#end
threads.each {|x| x.join}
收藏
举报
TAG: