Ruby中的Webdriver,如何运行测试用例x次

时间:2013-10-16 06:24:39

标签: ruby webdriver selenium-webdriver

我有一个用Ruby编写的Webdriver测试用例,如下所示,我想让它运行100次:

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

它确实喜欢它。

你能告诉我如何在我想要的时间内执行它吗?

感谢。

1 个答案:

答案 0 :(得分:1)

不确定你在这里尝试做什么,但试试这个

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

如果你想在每次调用时指定不同的次数,我会创建一个方法

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

然后您可以使用run_times 100

来调用它
相关问题