Kyle Schmitt
8/17/2007 1:32:00 PM
First a bit of general ruby stuff:
The $ infront of ie means it's global.
That can be useful when writing little one off methods for your
automation in irb, or when you're writing a script.
Does that help?
See,
foo=:local
$foo=:global
@foo=:class
@@foo=:shared_between_all_instances_of_class
These are _all_ different variables, they can each store a different
value, and have their own rules about where/when you can access them.
Try this
foo="local variable"
$foo="huge global variable"
@foo="class variable (but we can abuse it and treat it as global in
small scripts)"
def up()
$foo.upcase!
@foo.upcase!
end
up()
puts $foo
puts @foo
#now try
def bad
foo.upcase!
end
bad()
#You get an error here, since foo is local, it doesn't exist in the method!
#if this doesn't make much sense, try some of the 30 minute type ruby
#tutorials. I think it's hard to learn watir without a handle on the
basics of ruby :)
Now, onto the rest of it.
Humm, that showed up as a frame for me, but maybe they did some update?
Now, inside of irb, you only require watir once, doing it more than
once, won't hurt, but it will cough a bit.
Watir provides some nice .exists? methods; very useful when prodding
and poking a website with irb/watir.
$ie.link(:text,/play runescape/i).exists?
#That will tell you whether or not it exists!
#A quick & dirty thing to see all links is
$ie.links.each{|link| puts link}
#but my guess is that its in another stupid frame so if the previous line
#doesn't have the link you want, try
$ie.showFrames()