I have been in the software testing industry for many years, my own direction is also automated testing, VBScript script is also known, in the test process
Also applied, so let's talk about how to use VBScript to develop automated tests.
First, a few of the functions of VBScript that you can use in automated test development are introduced.
1. InStr function
Describe
Returns the position of the first occurrence of a string in another string.
Grammar
INSTR ([Start,]string1, string2[, compare])
The syntax for the INSTR function has the following parameters:
Parameter description
Start optional. A numeric expression that sets the starting position for each search. If omitted, the search begins at the position of the first character. If start contains Null, an error occurs. If you have specified compare, you must have the start argument.
String1 must be selected. The string expression that accepts the search.
string2 must be selected. The string expression to search for.
Compare optional. Indicates the numeric value of the comparison type to use when calculating the substring. For numeric values, see the "Settings" section. If omitted, a binary comparison is performed.
Example:
This function describes where a string appears in another string, and is often used as a comparison result in automated tests.
Like what:
Dim a,b
A= "Rtyi"
b= "1345krkrtyi:{" "><?"
If InStr (b,a) >0 Then
MsgBox "Test results passed"
Else
MsgBox "Test results failed"
End If
2. Split function
Describe
Returns a one-dimensional array based on 0 that contains the specified number of substrings.
Grammar
Split (expression[, delimiter[, count[, start]])
The syntax of the Split function has the following parameters:
Parameter description
Expression must be selected. A string expression that contains substrings and delimiters. If expression is a zero-length string, Split returns an empty array, which is an array that contains no elements and data.
Delimiter optional. The character used to identify the bounds of the substring. If omitted, use a space ("") as the separator. If delimiter is a zero-length string, returns the set of cell numbers that contain the entire expression string.
Count is optional. The number of substrings returned,-1 indicates that all substrings are returned.
Compare optional. Indicates the numeric value of the comparison type to use when calculating the substring. For numeric values, see the "Settings" section.
Example:
This function is primarily used for splitting strings, and is used primarily for splitting test data in automated test development.
Like what:
Dim A,b,i
A= "rt124,y556,57777,<>:/*&%"
B=split (A, ",")
For i=0 to Ubound (b)
MsgBox B (i)
Next