1

I have a Webdriver test case written in Ruby as below, and I want to make it run for example 100 times:

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

It does like it.

Can you show me how to execute it as many time as I want?

Thanks.

4

1 に答える 1

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

于 2013-10-16T15:10:41.210 に答える