|
按照<QTP自动化测试技术领航>一书中,常用网页十大控件的说明中,浏览器Browser&age,有一个实例,代码如下:
SystemUtil.Run "www.51testing.com"
Browser("micClass:=Browser").Navigate("bbs.51testing.com")
Browser("micClass:=Browser").Page("micClass:=Page").Sync:Wait 1
checkURL=Trim (Browser("micClass:=Browser").Object.LocationURL)
If checkURL="http://bbs.51testing.com/" Then
Reporter.ReportEvent micPass,"Step 1","assed"
Else
Reporter.ReportEvent micFail,"Step 1","Failed"
End If
Browser("micClass:=Browser").OpenNewTab:Wait 1
testHWND=Browser("name:=新建选项卡").GetROProperty("hwnd")
Browser("name:=新建选项卡").Navigate "bbs.51testing.com"
Browser("51Testing软件测试论坛-首页").Page("51Testing软件测试论坛-首页").Link("登录").Click
With Browser("51Testing软件测试论坛-首页").Page("51Testing软件测试论坛-用户登录")
.WebEdit("username").Set "malasyan"
.WebEdit("password").Set "831212"
.WebButton("登录").Click:Wait 3
End With
oExist=Browser("51Testing软件测试论坛-首页").Page("51Testing软件测试论坛-首页").Link("退出").Exist (3)
If oExist Then
Reporter.ReportEvent micPass,"Step 3","assed"
Else
Reporter.ReportEvent micFail,"Step 3","Failed"
End If
Browser("hwnd:="&testHWND).Close
Browser("micClass:=Browser").Refresh:Wait 1
oExist=Browser("51Testing软件测试论坛-首页").Page("51Testing软件测试论坛-首页").Link("退出").Exist (3)
If oExist Then
Reporter.ReportEvent micPass,"Step 4","assed"
Else
Reporter.ReportEvent micFail,"Step 4","Failed"
End If
运行后,首先QTP报错,如图:
回到IE浏览器发现页面并没有做任何跳转,也就是说代码第二行并没有实现.
然后看测试结果分析:Navigate一步的结果是Done
报错步骤截图:
请教大家这是怎么回事啊 |
|