user416299
user416299

Reputation: 21

Testing Auto-Complete Combo box in Selenium

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

Thanks for the help,

Manjide

Upvotes: 1

Views: 1406

Answers (2)

edA-qa mort-ora-y
edA-qa mort-ora-y

Reputation: 31931

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.

Upvotes: 1

pnewhook
pnewhook

Reputation: 4078

Take a look at my other answer Selenium - verify the list of suggestions is displayed

Upvotes: 1

Related Questions