Thanks alan, 

I got the solution thanks once again.


--- On Tue, 21/10/08, Alan Baird <[EMAIL PROTECTED]> wrote:
From: Alan Baird <[EMAIL PROTECTED]>
Subject: [wtr-general] Re: How to use Watir::Exception::TimeOutException
Date: Tuesday, 21 October, 2008, 10:05 AM

Chethan -
Here is how you would apply a timeout loop to the code you provided:
require 'test\unit'require 'timeout'

class MyTest < Test::Unit::TestCase  def test_sample_01    begin      
Timeout::timeout(3) do         require "testcase_01" # test cases      end
    rescue Timeout::timeout      puts "took too long"    end  end  def 
test_sample_02    begin      Timeout::timeout(1) do         require 
"testcase_02" # test cases
      end    rescue Timeout::timeout      puts "took too long"    end  endend
Where testcase_01 and testcase_02 are in separate ruby files and both look like 
puts "I am the first testcase"sleep 2
This is a pretty simple example, but it demonstrates the concept.  I have to 
say though, this is probably the most un-elegant way of doing this.  I've never 
actually require'd a testcase inside of Test::Unit to get it to run but it does 
work.  Seems like an easier way of doing this would be to wrap each test in 
it's own timeout at the method level.  If you did this, then your "batch" file 
would just be a series of requires.  

Consider the following:In testcase_01.rb:class MyTest < 
Test::Unit::TestCase  def test_sample_01    begin      Timeout::timeout(3) do 
        puts "I am the first testcase"        sleep 2      end    rescue 
Timeout::timeout      puts "took too long"    end  end
In testcase_02.rb:class MyTest < Test::Unit::TestCase  def test_sample_02    
begin      Timeout::timeout(1) do         puts "I am the first testcase"
        sleep 2      end    rescue Timeout::timeout      puts "took too long"   
 end  endend
Then, your batch file becomes:
require 'test\unit'require 'timeout'require 'testcase_01'
require 'testcase_02'
This is marginally better.  However, I'm noticing that I get an Error from Test 
Unit in the second example, as opposed to a Failure, not sure what is causing 

However, I'm still not even sure this will solve your problem if you got a 
modal pop-up box that froze your thread.  As I said earlier, I think you will 
need to look at trying to address the pop ups per testcase.

Maybe somebody else has some other ideas.  Let me know if you have any 

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to
Before posting, please read the following guidelines:
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to