2013-10-16 46 views
1

我有一个webdriver的测试情况如下用Ruby写的,我想,使其运行例如100倍:webdriver的在Ruby中,如何运行测试用例x次

require 'rubygems' 
require 'selenium-webdriver' 

$i = 0 
$num = 100 
while $i<$num do 

    driver = Selenium::WebDriver.for :firefox 

    driver.get "https://dev08-olb.nz.thenational.com/ib4b/app/login" 
    # some other test which require $i to be incremental as unique ID 
    driver.close 

i++ 

end 

它确实喜欢它。

你能告诉我如何执行它尽可能多的时间吗?

谢谢。

+0

你说哪个代码块多次运行?你有什么尝试?你期望什么行为,你取得了什么? – Seanny123

回答

1

不知道你正试图在这里做的,但如果你想在每次调用我将创建一个方法

def run_times(n) 
    n.times do |i| 
    #INSERT YOUR BLOCK TO RUN HERE 
    end 
end 

时间指定不同的多次尝试这种

num = 100 
num.times do |i| 
    #INSERT YOUR BLOCK TO RUN HERE i will increment from 0..num 
end 

那么你可以打电话给run_times 100

+0

谢谢你 – nzsquall

相关问题