Requirement:
1. Navigate to Google.com
2. Type “Ravee” in text Field
3. Select “Raveendran” from Auto Complete option from Suggested option.
Steps to Solve the issues:
1. Navigate to Google.com
2. Type “Rav” in text Field
3. Using IE Developer Tool Bar –> Click The suggested Option (So You will get the source code for suggestion lists)
4. Find the parent id –> Ex. It should TABLE mostly.
So we have Table id/name/class
5. Collect All the Rows under this table
6. Check the text for each and every row
7. If Any one of the row matches “Raveendran”
8. Then Simply Click It
Code:
require 'rubygems'
require 'watir-webdriver'
browser=Watir::Browser.new :ie
browser.goto("google.com")
browser.text_field(:name,"q").set("Ravee")
sleep 3
auto_content=browser.table(:class,'gssb_m').trs
auto_content.each do |g|
if g.text.downcase == "raveendran"
g.click
sleep 3
break
end
end
Demo –> http://bit.ly/j_autocomplete_watir