jim che asked:
I want to detect the number of certain word in a page .For example in a page
there contains 20 'Hello' and I want to get the number of 'Hello'
   How can I detect it which apis can be used?

Watir::IE#text returns the text in the page (excluding titles, tags, etc) as a String. String#scan(regexp) returns an array of the bits of the string that match the regexp.
Array#size returns the number of elements in the array.

require 'watir'
ie = Watir::IE.new
ie.goto("http://hello.com";)
p ie.text.scan(/hello/i).size

Cheers
Dave
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to