|
Copy到QTP中可直接执行。为了方便被执行,脚本全改写成描述性编程的方式了。脚本主要是用父对象的思想来解决问题。
对搜索出来的链接的是否为子链接做了判断,如果不需要区分只需删除掉desc("x").value = 18就好了。
- SystemUtil.CloseProcessByName "iexplore.exe"
- SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE","http://www.google.cn",,,3
- Browser(":=").Page(":=").WebEdit("name:=q").Set "testing"
- Browser(":=").Page(":=").WebEdit("name:=q").Submit
- Set desc = Description.Create()
- desc("micclass").value = "WebElement"
- desc("html tag").value = "LI"
- desc("class").value = "g"
- desc("x").value = 18
- Set odesc = Description.Create()
- odesc("micclass").value = "Link"
- set oWEs = Browser(":=").Page(":=").ChildObjects(desc)
- If oWEs.Count >= 10 Then
- iCount = 10
- Else
- iCount = oWEs.Count
- End If
- For i=1 to iCount
- Set oLinks = oWEs(i-1).ChildObjects(odesc)
- oLinks(0).Click
- Browser("CreationTime:=1").Close
- Next
- Set desc = Nothing
- Set odesc = Nothing
复制代码
[ 本帖最后由 hsjzfling 于 2009-4-8 18:54 编辑 ] |
|