John, Asking the obvious, if you don't want the code to run, why not remove it or comment it out? I'm not entirely sure what you are after, so a general response which I hope may still be useful.
Firstly, the protected code block has the structure: begin expr.. [rescue [error_type,..] expr..].. [else expr..] [ensure expr..] end In this, the "end" statement ends the block. It does not stop the program running. In this case, the end statement after your puts 'please login..' line closes the begin block. To stop the program / script running, call the 'exit' method. Alternatively, if you want to build in behaviour around the lack of a browser, you could always use an if-block: if browser # do stuff when you have a browser else # do stuff when you have no browser (browser = nil) end Alex On 26 Apr 2009, at 07:01, «°¤§ømåtïçCðrp§ë¤°» wrote: > > I'm running a script, which has a rescue clause, but I want it to > (essentially) break, when the rescue clause is invoked. > > Instead, it runs to the next line: > > C:\Documents and Settings\Marissa\Desktop>ruby T3.rb > What is the user's First Name? > Test > What is the user's Last Name? > Test > ALERT: You must have a running instance of SVC open! > Please log into SVC and restart Sevin. Exiting: Code1. > T3.rb:18: undefined method `frame' for nil:NilClass (NoMethodError) > > To state the obvious: The frame it's looking for is not going to be > there, so I don't even want it to go there. > > [Code] > > > require 'watir' > > puts "What is the user's First Name?" > Fname = gets.chomp #Removes return (recognized as new line command) > character '\n' > puts "What is the user's Last Name?" > Lname = gets.chomp #Removes return (recognized as new line command) > character '\n' > > begin > @browser = Watir::IE.attach(:url, 'https:// > www.servicecenterweb.unisys.com/sc2/index.do') > rescue Watir::Exception::NoMatchingWindowFoundException > puts "ALERT: You must have a running instance of SVC open!" > @browser1 = Watir::IE.new > @browser1.goto('https://www.servicecenterweb.unisys.com/sc2/ > index.do') > puts "Please log into SVC and restart Sevin. Exiting: Code1." > end > @browser.frame(:id, 'detail').button(:id, 'X8').click > #Insert company name and user > @browser.frame(:id, 'detail').text_field(:id, 'X7').set("BAXTER") > @browser.frame(:id, 'detail').text_field(:id, 'X78').set(Fname) > @browser.frame(:id, 'detail').text_field(:id, 'X80').set(Lname) > [/Code] > > If I put a 'break' in the rescue clause, it doesn't seem to like it, > and 'end' really doesn't "end", as you can see. > > So, is there a way I can ditch the script, if the rescue is invoked, > or will I just have to deal with it going on to the next line? > > Thanks! > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---