Interaction Functions:
When running automation scripts, we usually don’t use interactions function of any type, because the idea of automation testing, is testing without the need of human resources, and “interaction” means, that you need a human, to make a decision, input required data, or whatever other task.
Two Iterative Functions available in VB Script.
InputBox Function
MsgBox Function
InputBox Function:
Description:
The InputBox function displays a dialog box containing a label, which prompts the user about the data you expect them to input, a text box for entering the data, an OK button, a Cancel button, and optionally, a Help button. When the user clicks OK, the function returns the contents of the text box.
Syntax: InputBox(prompt,title,default,xpos, ypos, helpfile, context)
Arguments:
Parameter Description
prompt The message in the dialog box.
title The title-bar of the dialog box.
default String to be displayed in the text box on loading.
xpos The distance from the left side of the screen to the left side of the dialog.
ypos The distance from the top of the screen to the top of the dialog box.
helpfile The Help file to use if the user clicks the Help button on the dialog box.
context The context number to use within the Help file specified in helpfile.
Notes:
InputBox returns a string containing the contents of the text box from the Input-box dialog.
If the user clicks Cancel, a zero-length string (" ") is returned.
Prompt can contain approximately 1,000 characters, including nonprinting characters like the intrinsic vbCrLf constant.
If you don't use the default parameter to specify a default entry for the text box, the text box is shown empty; a zero-length string is returned if the user doesn't enter anything in the text box prior to clicking OK.
xpos and ypos are specified in twips. A twip is a device-independent unit of measurement that equals 1/20 of a point or 1/1440 of an inch.
If the xpos parameter is omitted, the dialog box is centered horizontally.
If the ypos parameter is omitted, the top of the dialog box is positioned approximately one-third of the way down the screen.
If the helpfile parameter is provided, the context parameter must also be provided, and vice versa.
In VBScript, when both helpfile and context are passed to the InputBox function, a Help button is automatically placed on the InputBox dialog, allowing the user to click and obtain context-sensitive help.
Example:
sString = InputBox("Enter it now", , "Something", , , "help.hlp", 321321)
MsgBox Function:
Description:
Displays a dialog box containing a message, buttons, and optional icon to the user. The action taken by the user is returned by the function as an integer value.
Syntax:
MsgBox(prompt, buttons, title, helpfile, context)
Arguments:
Parameter Description
prompt The text of the message to display in the message box dialog.
Buttons The sum of the Button, Icon, Default Button, and Modality constant Values
Title The title displayed in the Title-bar of the message box dialog.
Helpfile An expression specifying the name of the help file to provide help functionality for the dialog.
context An expression specifying a context ID within helpfile.
Example:
MsgBox “Welcome to VB Script”
No comments:
Post a Comment