1. Reporter对象的ReportEvent方法
描述
在test result中报告测试结果。
Reporter.ReportEvent EventStatus, ReportStepName, Details [, in]
举例: 下面的例子使用ReprotEvent方法来报告一个失败信息。
Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed."
Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed."
在运行脚本的过程中,弹出对话框,等待用户手工点击按钮干预。本语句根据用户点击按钮的情况得到返回值。
这个语句适用于脚本的调试过程。
Ø 语法
MsgBox(prompt[, buttons][, title][, helpfile, context])
Ø 参数
prompt 将在对话框中显示的信息。最大长度为1024字符。如果内容有多行,可以用(Chr(13))来表示回车符,或用(Chr(10))表示换行符,或用(Chr(13) & Chr(10))表示回车-换行符。
buttons 按钮的值。默认值为0。
title 弹出框的标题,将显示在标题栏。
Ø Settings
按钮值的说明:
内容 | 值 | 描述 |
vbOKOnly | 0 | 只显示OK按钮 |
vbOKCancel | 1 | 显示OK以及Cancel按钮。 |
vbAbortRetryIgnore | 2 | 显示Abort、Retry以及Ignore按钮。 |
vbYesNoCancel | 3 | 显示Yes、No以及Cancel按钮 |
vbYesNo | 4 | 显示Yes和No按钮 |
vbRetryCancel | 5 | 显示Retry和Cancel按钮 |
vbCritical | 16 | Display Critical Message icon. |
vbQuestion | 32 | Display Warning Query icon. |
vbExclamation | 48 | Display Warning Message icon. |
vbInformation | 64 | Display Information Message icon. |
vbDefaultButton1 | 0 | First button is default. |
vbDefaultButton2 | 256 | Second button is default. |
vbDefaultButton3 | 512 | Third button is default. |
vbDefaultButton4 | 768 | Fourth button is default. |
vbApplicationModal | 0 | 应用程序模式。用户必须对信息框做出响应,脚本运行才能继续。 |
vbSystemModal | 4096 | 系统模式。所有的应用被挂起,直到用户对信息框做出响应。 |
Ø 返回值
MsgBox功能的返回值
内容 | 值 | 按钮 |
vbOK | 1 | OK |
vbCancel | 2 | Cancel |
vbAbort | 3 | Abort |
vbRetry | 4 | Retry |
vbIgnore | 5 | Ignore |
vbYes | 6 | Yes |
vbNo | 7 | No |
用 变量名=MsgBox(prompt[, buttons][, title][, helpfile, context])的方法获取返回值。
3. InputBox函数
弹出对话框,等待用户输入内容或点击按钮。返回值是输入的内容。
Ø 语法
InputBox(prompt[, title][, default][, xpos][, ypos][, helpfile, context])
Ø Arguments
prompt 将在对话框中显示的信息。最大长度为1024字符。如果内容有多行,可以用(Chr(13))来表示回车符,或用(Chr(10))表示换行符,或用(Chr(13) & Chr(10))表示回车-换行符。
title 弹出框的标题,将显示在标题栏。
default 输入框的默认值。
Ø 例
Dim Input
Input = InputBox("Enter your name")
MsgBox ("You entered: " & Input)
在一个弹出框中显示文本信息。
Ø 语法
intButton = object.Popup(strText,[nSecondsToWait],[strTitle],[nType])
Ø Arguments
object WshShell对象.
strText 希望在弹出框中显示的文本信息。
nSecondsToWait 可选。希望弹出框保持显示的最长时间。(单位秒)。
strTitle 弹出框的标题
nType 一个数值,代表希望在弹出框中显示的按钮或图标。这个值决定了如何使用信息框。
IntButton 返回值。表示用户点击的按钮值。
Ø 注意
无论which host executable file is running (Wscrīpt.exe or Cscrīpt.exe),Popup method都会弹出信息框。
如果nSecondsToWaitis 为0,弹出框一直等到用户干预才关闭。如果nSecondsToWaitis 大于0,如果没有用户干预,则弹出框一直等到nSecondsToWaitis时间后自动关闭。
如果不设置“strtitle”,则弹出框的标题默认为"Windows scrīpt Host."。
“nType”的意思与MessageBox function的ntype相同。
按钮值
值 | 描述 |
0 | 显示OK按钮. |
1 | 显示OK及Cancel按钮。 |
2 | 显示Abort, Retry, 及Ignore按钮。 |
3 | 显示Yes, No, 及Cancel按钮。 |
4 | 显示Yes及 No按钮。 |
5 | 显示 Retry 及 Cancel按钮。 |
图标类型值
值 | 描述 |
16 | 显示"Stop Mark"图标。 |
32 | 显示 "Question Mark"图标。 |
48 | 显示 "Exclamation Mark"图标。 |
64 | 显示"Information Mark"图标。 |
返回值
如果用户没有在窗口等待的时间范围内(nSecondsToWait)点击按钮,则返回-1。
值 | 描述 |
1 | OK按钮 |
2 | Cancel 按钮 |
3 | Abort 按钮 |
4 | Retry 按钮 |
5 | Ignore 按钮 |
6 | Yes 按钮 |
7 | No 按钮 |
Ø Example
[VBscrīpt]
Dim WshShell, BtnCode
Set WshShell = Wscrīpt.CreateObject("Wscrīpt.Shell")
BtnCode = WshShell.Popup("Do you feel alright?", 7, "Answer This Question:", 4 + 32)
Select Case BtnCode
case 6 Wscrīpt.Echo "Glad to hear you feel alright."
case 7 Wscrīpt.Echo "Hope you're feeling better soon."
case -1 Wscrīpt.Echo "Is there anybody out there?"
End Select