Execution stops once exception is encountered

V

Vishwanath Uppala

Hi all,

I am using ruby and watir to test my web application.
I wanna run watir script 24 x 7 without stopping.
The problem is that the ruby stops execution each time
it encounters an exception for e.g if it fails to locate
a frame on a web page it gives out exception and stops executing.

Is there any way by which i can continue execution of the script
even after encountering exceptions.

Thanking you in advance

Regards
vishwanath
 
G

Gerardo Santana Gómez Garrido

2007/10/12 said:
Hi all,

I am using ruby and watir to test my web application.
I wanna run watir script 24 x 7 without stopping.
The problem is that the ruby stops execution each time
it encounters an exception for e.g if it fails to locate
a frame on a web page it gives out exception and stops executing.

Is there any way by which i can continue execution of the script
even after encountering exceptions.

Thanking you in advance

Regards
vishwanath


Sure, you can literally rescue the offending code. Take a look at this example:

$ cat test.rb
2.downto(-2) {|i|
begin
puts "10/#{i} == #{10/i}"
rescue => e
puts e.message
end
}
$ ruby test.rb
10/2 == 5
10/1 == 10
divided by 0
10/-1 == -10
10/-2 == -5
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top