tags:

views:

108

answers:

2

Has anyone a good solution on how to test auto-complete combo box in Selenium?

Thanks for the help,

Manjide

+1  A: 

Using TestPlan with the Selenium back-end this code grabs the suggestions from Google -- which is an example of a auto-complete combo box.

GotoURL http://www.google.com/webhp?hl=en
ClickReplaceType //input[@name='q'] what is my

# This is where the suggestions appear
set %ResultsXPath% //table[@class='gac_m']//td[@class='gac_c']

# Check that they are there (that is, wiat for them, since they are dynamic)
Check %ResultsXPath%

# Then iterate over the suggestions
foreach %Cell% in (response %ResultsXPath%)
    Notice %Cell%
end

This produces the results:

00000000-00 GOTOURL http://www.google.com/webhp?hl=en
00000001-00 NOTICE Starting a new browser (0:0:0:0:1) com.thoughtworks.selenium.DefaultSelenium@332611a7
00000002-00 NOTICE what is my ip
00000003-00 NOTICE what is my ip address
00000004-00 NOTICE what is my bmi
00000005-00 NOTICE what is my house worth
00000006-00 NOTICE what is my

Usually such tests work in both the Selenium and HTMLUnit backend in TestPlan, but Google currently works with Selenium.

edA-qa mort-ora-y