Thanks all for the responses.  I like the rescue nil trick, never thought of 
that.

Alan

-----Original Message-----
From: watir-general+ow...@googlegroups.com 
[mailto:watir-general+ow...@googlegroups.com] On Behalf Of b...@pettichord.com
Sent: Tuesday, December 08, 2009 6:35 PM
To: Watir General
Subject: [wtr-general] Re: better way to do a conditional require

require 'watir/contrib/visible' rescue nil

On Dec 7, 5:12 pm, Bill Agee <billa...@gmail.com> wrote:
> You might be able to use Watir::IE::VERSION:
>
> require 'watir'
> require 'watir/contrib/visible' if Watir::IE::VERSION != '1.6.5'
>
> But I guess that will only work so long as nothing newer than 1.6.5 exists.
> Since the version value is a string, it might need to be massaged a bit if
> you want to compare it to higher or lower versions.
>
> I notice that there's also FireWatir::Firefox::VERSION (with the same
> value), but no Watir::VERSION constant. :)  That could be nice to have
> eventually.
>
> Thanks
> Bill
>
> On Mon, Dec 7, 2009 at 2:47 PM, Alan Baird <aba...@bairdsnet.net> wrote:
> > I'm wondering if there is a decent way to do a conditional require.  My
> > specific problem is that my framework includes the old .visible? code  by
> > requiring 'watir/contrib/visible'.  After upgrading to 1.6.5 I don't want to
> > do this anymore since the .visible? method is included in the main watir
> > core.  However, since I use some shared resources in my team, I wanted to be
> > able to use 1.6.5 on my machine and not require a global update, I needed a
> > way to conditionally require 'watir/contrib/visible' only if the code is
> > earlier than 1.6.5.
>
> > So, I came up with the following hack:
>
> > require 'watir/contrib/visible' unless
> > Watir::Element.instance_methods.include?('visible?')
>
> > ...but there's got to be a better way.  Something like:
>
> > require 'watir/contrib/visible' if Watir < 1.6.5
>
> > Any ideas?
>
> > Alan
>
> > --
> > 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

--
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

This email message and any attachments are for the sole use of the intended 
recipients and may contain proprietary and/or confidential information which 
may be privileged or otherwise protected from disclosure. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you are not an 
intended recipient, please contact the sender by reply email and destroy the 
original message and any copies of the message as well as any attachments to 
the original message.

-- 
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

Reply via email to