|
这个是我自己写的,有js错误的html
<html>
<head><title>test's test</title>
<script language="javascript">
function a()
{
alert("aa
}
a();
</script>
</head>
<body>
<h1>Just a Test</h1>
</body>
</html>
然后我将其保存为b.html放在桌面,下面是我录制的qtp
Dim myStr
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE","","C:\Documents and Settings\server","open"
ConfigMyIE
Browser("Browser").Navigate "C:\Documents and Settings\server\Desktop\b.html"
myStr = Browser("Browser").WinStatusBar("msctls_statusbar32").GetItemProperty(statuebartext,"text") 'print the text
Browser("Browser").Window("Internet Explorer").Page("Internet Explorer").WebButton("OK").Click 'Press button OK
Browser("Browser").Page("Page").Sync 'The page
ConfigMyIE
If myStr = "Error on page." Then
MsgBox "Script Error"
Reporter.ReportEvent micFail ,"Script " , "error"
Else
MsgBox "All Done"
Reporter.ReportEvent micPass,"Script","No Error"
End If
Browser("Browser").Close 'Close the browser
Sub ConfigMyIE
'config my IE
Browser("Browser").WinToolbar("ToolbarWindow32").Press "&Tools"
Browser("Browser").WinMenu("ContextMenu").Select "Internet Options..."
Browser("Browser").Dialog("Internet Options").WinTab("SysTabControl32").Select "Advanced"
Browser("Browser").Dialog("Internet Options").WinTreeView("Settings:").Select "Browsing;Display a notification about every script error"
Browser("Browser").Dialog("Internet Options").WinTreeView("Settings:").Activate "Browsing;Disable script debugging"
Browser("Browser").Dialog("Internet Options").WinButton("OK").Click
End Sub
|
|