Archive

Archive for the ‘watir’ Category

Be careful to “include Watir”

October 29th, 2009 No comments

When we have the “include Watir”, then we cannot load another ruby file.

I spent more than 1 hour to figure out this.

Categories: watir Tags:

watir to count the links in a search list on a webpage

October 27th, 2009 No comments

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

Categories: watir Tags: ,

Gems for web scrape

October 23rd, 2009 No comments

I just put the names of the gems here for future reference:
hpricot
nokogiri
mechanize
webrat
scrubyt

Categories: watir Tags: , , , ,

The most useful site for watir

October 23rd, 2009 No comments

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.

Categories: watir Tags:

pay attention to attach the IE window when elements not found by watir

October 11th, 2009 No comments

Several times I spend several hours to identify an element, the element is there, but watir can not find it.

I click a link and a new IE window comes up, and forget to attach the new IE window, so watir and me are looking for elements on different windows.

Categories: watir Tags: ,

flash an element in watir

May 7th, 2009 No comments

When debugging the scripts of the watir application, there may be a need to flash an element, following is the code:

ie.element_by_xpath(” “).flash

Categories: watir Tags: