2010-09-10 108 views

回答

1

使用TestPlan與硒後端這段代碼從谷歌抓取的建議 - 這是一個自動完成組合框的示例。

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) [email protected] 
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 

通常這種測試在測試計劃的硒和後端的HtmlUnit都工作,但谷歌目前正在與硒的作品。