在Selenium中测试自动完成组合框

时间:2010-09-10 15:08:22

标签: selenium

有没有人如何在Selenium中测试自动完成组合框?

感谢您的帮助,

Manjide

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

TestPlan与Selenium后端一起使用,此代码会抓取Google的建议 - 这是自动完成组合框的示例。

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

这会产生结果:

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

通常此类测试在TestPlan中的Selenium和HTMLUnit后端都有效,但Google目前与Selenium合作。