Be careful to “include Watir”
When we have the “include Watir”, then we cannot load another ruby file.
I spent more than 1 hour to figure out this.
When we have the “include Watir”, then we cannot load another ruby file.
I spent more than 1 hour to figure out this.
When writing the first few Ruby programs, there is a tend to place all the code in a single file. But as time passes by and the Ruby programs grow, it is nature that at some point we have to break our code up into logical groupings and place each group in a separate file or files.
following is an examle:
in foo.rb:
puts “it is foo”
$foo = 3 # $ for global variable
in bar.rb:
puts “it is bar”
$bar = 3 # $ for global variable
in test.rb:
require ‘foo’ # pay attention –no “.rb”
load ‘bar.rb’ # pay attention — “.rb” is there
test = 1 + $foo + $bar
when execute test.rb, it shows :
it is foo
it is bar
9
Some times I need to check the amount of the links in a search list, at first I try and failed by:
ie.links(:id, /bra bra/).length
and then I find a solution by:
ie.div(:id, “searchList”).links
and then by googles, I find a better solution:
links_searchlist = ie101.links.find_all { |link| link.class_name == ‘permalink’ }
puts “the links in the searchlist:”
puts links_searchlist.length
and in another case, following code also works:
searchlistlinks = ie102.links.find_all { |link| link.id =~ /hitURL/ }
links_searchlist = searchlistlinks.length
puts links_searchlist
following can also work:
searchlistlinks = ie33.links.find_all { |link| link.href =~ /something/ }
but be careful that the following (url) will not work:
searchlistlinks = ie33.links.find_all { |link| link.url =~ /something/ }
Recently I found the best solution by google:
links = ie51.div(:id, ‘threadlist’).html.scan(/something/).count
puts links
I just put the names of the gems here for future reference:
hpricot
nokogiri
mechanize
webrat
scrubyt
I always googles when I encounter any problem related to watir, but after these years’ practice, I will state that the most useful site for watir is http://wtr.rubyforge.org/rdoc/, most answer is already there.
There is a tendency for regular visitors to your site to ignore adsense ads, this occurs when the ads is in same selected color palette and in the same location.
To prevent regular users from ad blindness, you can officially rotate upto 4 different types of color palettes for your adsense ads.
When you are selecting the color scheme for the adsense ads, just select multiple color schemes.
Now you will see 4 selected schemes beside each other and will also be incorporated in the adsense code. This color coding will now be changed automatically whenever the page is reloaded.