# Modules, require, include, toplevel constants and Watir

**URL:** <https://www.ruby-forum.com/t/modules-require-include-toplevel-constants-and-watir/163891>\
**Category:** Ruby\
**Created:** [March 25, 2009, 10:21pm UTC](https://www.ruby-forum.com/t/modules-require-include-toplevel-constants-and-watir/163891 "2009-03-25T22:21:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chadmontplaisir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@chadmontplaisir](https://www.ruby-forum.com/u/chadmontplaisir)\
**Post date:** [March 25, 2009, 10:21pm UTC](https://www.ruby-forum.com/t/modules-require-include-toplevel-constants-and-watir/163891/1 "2009-03-25T22:21:22Z")

</div>

Hi guys,

Despite working in IT for almost 2 years now I consider myself a  
programming novice. Its probably my art degree. Anyway, I’m having  
trouble figuring out what is going on here.

I’m using Watir here, but I suppose this would hold true with any  
module.

To give a little background. As far as I can tell, the Watir module  
holds the IE class which holds the WinClicker class

This is the code:  
Code:

require ‘watir’

WinClicker.new

This will throw an error saying that the constant WinClicker is  
uninitialized

Now, if I do this  
Code:

require ‘watir’

Watir::IE  
WinClicker.new

It works.

It also works with:  
Code:

require ‘watir’  
include Watir  
WinClicker.new

However, it is not a good idea to include Watir. In 1.6.2 of watir,  
including it can break scripts and I’m told its generally a poor idea to  
include at the global level.

If I use:  
Code:

require ‘watir’  
Watir::IE::WinClicker.new

I get a warning in the way I am referencing the toplevel class  
WinClicker.

My questions are:

1. What is Watir::IE doing in the second code example that allows me to  
then use WinClicker
2. Is doing a Watir::IE the same as including Watir?
3. What does that warning when referencing Watir::IE::WinClicker imply  
and what problems can arise from doing that?
4. If anyone knows, how should I be dealing with the creation of new  
WinClicker objects so as to avoid the warning AND avoid including Watir.

Thanks a million.

---

<div class="post-metadata">

**Author:** ![chadmontplaisir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@chadmontplaisir](https://www.ruby-forum.com/u/chadmontplaisir)\
**Post date:** [March 26, 2009, 1:40am UTC](https://www.ruby-forum.com/t/modules-require-include-toplevel-constants-and-watir/163891/2 "2009-03-26T01:40:47Z")

</div>

On Wed, Mar 25, 2009 at 4:18 PM, Chad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. What is Watir::IE doing in the second code example that allows me to  
> then use WinClicker

There is an autoload set on Watir::IE. This is new with Watir 1.6.

It is the same as “require ‘watir/ie’”. This is probably what you want  
to do  
now.

–  
Bret P.  
CTO, WatirCraft LLC, [www.watircraft.com](http://www.watircraft.com)  
Lead Developer, Watir, [www.watir.com](http://www.watir.com)

Blog, [www.io.com/~wazmo/blog](http://www.io.com/~wazmo/blog)  
Twitter, [www.twitter.com/bpettichord](http://www.twitter.com/bpettichord)  
GTalk: removed\_email\_address@domain.invalid

Watir Training: Portland/Beaverton April 16-17  
[www.watircraft.com/training](http://www.watircraft.com/training)

---

<div class="post-metadata">

**Author:** ![chadmontplaisir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@chadmontplaisir](https://www.ruby-forum.com/u/chadmontplaisir)\
**Post date:** [March 27, 2009, 10:59am UTC](https://www.ruby-forum.com/t/modules-require-include-toplevel-constants-and-watir/163891/3 "2009-03-27T10:59:51Z")

</div>

That explains a lot. Thanks Bret. As it turns out, I was previously  
using ‘watir/ie’ before but I had the insane notion that the ie.rb  
file’s name was in caps so I was using ‘watir/IE’ which gave a different  
warning about the constant ATTACHER already being initialized. I am  
totally baffled on what made me think this but what can ya do. Anyway,  
thanks again.

Chad
