I have been in the software testing industry for many years, and I want to perform automated testing. I also know about VBScript. During the testing process
Some applications are also applied, so let's talk about how to use Vbscript to develop automated testing.
First, we will introduce several VBScript functions that can be used in automated testing and development.
1. instr Functions
Description
Returns the position where a string appears for the first time in another string.
Syntax
Instr ([start,] string1, string2 [, compare])
The syntax of the instr function includes the following parameters:
Parameter description
Start is optional. Value expression, used to set the start position of each search. If omitted, the search starts from the first character. If start contains null, an error occurs. If the compare parameter is specified, the start parameter is required.
String1 is required. String expression to be searched.
String2 is required. The string expression to be searched.
Compare is optional. Indicates the value of the comparison type used to calculate the substring. For values, see the "Settings" section. If omitted, binary comparison is executed.
Example:
This function indicates the position where a string appears in another string. It is often used as a comparison result in automated testing.
For example:
Dim a, B
A = "rtyi"
B = "1345 krkrtyi: {" "> <? "
If instr (B, A)> 0 then
Msgbox "Test Result passed"
Else
Msgbox "test result failed"
End if
2. Split Function
Description
Returns a zero-dimensional array containing a specified number of substrings.
Syntax
Split (expression [, delimiter [, Count [, start])
The syntax of the split function includes the following parameters:
Parameter description
Expression is required. A string expression that contains a substring and a separator. If expression is a zero-length string, split returns an empty array, that is, an array that does not contain elements and data.
Delimiter is optional. Character used to identify the substring boundary. If omitted, use space ("") as the separator. If Delimiter is a zero-length string, a single element array containing the entire expression string is returned.
Count is optional. Number of substrings to be returned.-1 indicates that all substrings are returned.
Compare is optional. Indicates the value of the comparison type used to calculate the substring. For values, see the "Settings" section.
Example:
This function is mainly used to split strings and split test data in automated testing and development.
For example:
Dim A, B, I
A = "rt124, y556, 57777, <>:/ * & %"
B = Split (,",")
For I = 0 to ubound (B)
Msgbox B (I)
Next