On Thu, Sep 29, 2011 at 10:05 PM, Sat nosur [email protected] wrote:
display an exception and continue executing the script
Could please take a look at the script ( Click method)
and help me to resolve this issue?. Advance thanks for your help
Yours,
Sat
Attachments:
http://www.ruby-forum.com/attachment/6640/isell_regression_script_raise_syntax_error.rb
If you indent your code, you will see it more clearly:
def Click(ie,id,verifyval)
begin
writeln 'CLICK- ’ + id
if id.exists?
$ie.button(:id, id).click
if id == 'TriggerFeedAnchor'
sleep 10
elsif id == 'onestop'
sleep 20
else
sleep 8
end
else
raise Exception "ID RETURNED #{id}."
rescue Exception => e
puts e.message
puts $!
break
end
end
if $ie.contains_text(verifyval)
puts "Test Passed. Found the string: on the page #{verifyval}. "
else
puts "Test Failed! Could not find the string on the page:
#{verifyval} "
end
end
After the raise, you have to close the if with an end. Rescue comes at
the same scope (same indentation level) as begin. With that fixed, now
you have an extra “end” after "break. You need to remove that:
def Click(ie,id,verifyval)
begin
writeln 'CLICK- ’ + id
if id.exists?
$ie.button(:id, id).click
if id == 'TriggerFeedAnchor'
sleep 10
elsif id == 'onestop'
sleep 20
else
sleep 8
end
else
raise Exception "ID RETURNED #{id}."
end
rescue Exception => e
puts e.message
puts $!
break
end
if $ie.contains_text(verifyval)
puts "Test Passed. Found the string: on the page #{verifyval}. "
else
puts "Test Failed! Could not find the string on the page:
#{verifyval} "
end
end
Hope this helps,
Jesus.