I can't say if the approach you're using is viable or not because I'm
not clear on your intended goal, but if you're trying to get just the
number after SystemExit try:

$variable = $variable.split("SystemExit")[1]

If I knew what test framework you were using, I could probably offer
an easier way to fail a test and send an email.  For test/unit:

begin
  assert_match(/testing/, @browser.text)
  (actions for PASS go here)
rescue => e
  (actions for FAIL/error go here)
end #begin

On Apr 14, 5:22 pm, Shlomit Gazit <[email protected]> wrote:
> Somehow #{$!.class} prints as: SystemExit1 or SystemExit0, which is
> the opposite than what I see on the console in Irb: Exit code: 0,
> Error code: 1.
> In any case I need only the numbers 1 or 0 without the word
> SystemName, any idea?
> I wrote a script to send email if the test is failing.
> For now I am setting variable to 0 when initializing the test, and 1
> at the end of the test, if it is not failing, the variable is set to
> 1.  But I prefer to not depends on that.
>
> On Apr 14, 2:00 pm, Ethan <[email protected]> wrote:
>
> > as Charley said, watir does not exit, itself.
> > If you want to know if an exception occurred causing your program to exit,
> > you can check if the global exception variable, $! is set.
> > at_exit do
> >   if $!
> >     print "an exception occurred of type #{$!.class}"
> >   end
> > end
> > or something along those lines.
>
> > On Wed, Apr 14, 2010 at 16:36, Charley Baker <[email protected]>wrote:
>
> > > Watir itself doesn't have an exit code, it's just a library. Are you
> > > talking about your own testing framework, rspec, test::unit? Those 
> > > generally
> > > can set exit codes. My question is what are you trying to do? Set it up 
> > > in a
> > > CI run? Something else entirely?
>
> > > -c
>
> > > On Wed, Apr 14, 2010 at 2:30 PM, Shlomit Gazit 
> > > <[email protected]>wrote:
>
> > >> Is there a method to use watir exit code (0 or 1)?
> > >> I want to know that if it is 0 to do something at_exit.
>
> > >> Thank you, Shlomit.
>
> > >> --
> > >> Before posting, please readhttp://watir.com/support. In short: search
> > >> before you ask, be nice.
>
> > >> You received this message because you are subscribed to
> > >>http://groups.google.com/group/watir-general
> > >> To post: [email protected]
>
> > >> To unsubscribe, reply using "remove me" as the subject.
>
> > >  --
> > > Before posting, please readhttp://watir.com/support. In short: search
> > > before you ask, be nice.
>
> > > You received this message because you are subscribed to
> > >http://groups.google.com/group/watir-general
> > > To post: [email protected]
>
>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: [email protected]

Reply via email to