|
5#
楼主 |
发表于 2009-6-17 11:49:00
|
只看该作者
qtp和 google继续
冒个泡,写点东西,希望能够有用
Option Explicit
Sub testGoogle
Dim obj1,obj2,counts,i,txt,lens,lenss,tlen
Set obj1 = Description.Create()
obj1("class").value="l"
wait(2)
With Browser("MicClass:=Browser").Page("MicClass:=Page")
wait(2)
set obj2 =.ChildObjects(obj1)
counts = obj2.count
For i=0 to counts-1
txt=obj2(i).GetROProperty("innertext")
lens=Instr(txt,"php")
lenss=instr(txt,"PHP")
tlen=lens+lenss
If tlen=0 Then
reporter.ReportEvent micFail,"cann't find the word","cann't find the word"
End If
Next
End with
End Sub
Sub main()
Dim pagecount
SystemUtil.CloseProcessByName("iexplore.exe")
SystemUtil.Run "iexplore.exe","http://www.google.cn"
wait(2)
With Browser("MicClass:=Browser").Page("MicClass:=Page")
pagecount=0
.WebEdit("name:=q").Set "php"
.WebButton("name:=Google 搜索").click
Do while true
pagecount=pagecount+1
If pagecount =1 Then
Call testGoogle
else
If .Link("text:="&pagecount,"html tag:=A").Exist(2) Then
.Link("text:="&pagecount,"html tag:=A").click
wait(2)'等待页面刷新,可以设置同步点
Call testGoogle
else
Exit do
End If
End If
Loop
End with
SystemUtil.CloseProcessByName("iexplore.exe")
End Sub
Call main() |
|