I have been in the software testing industry for many years, and my direction is automatic testing. I also know about VBScript script in the process of testing
Also used some, so to talk about how to use VBScript to develop automated testing.
First of all, several VBScript functions that can be used in automatic test development are introduced.
1. Instr function
Returns the position of the first occurrence of a string in another string.
InStr([start, ]string1, string2[, compare])
The syntax of the instr function has the following parameters:
Start is optional. A numeric expression that sets the starting position of each search. If omitted, the search starts at the position of the first character. If start contains null, an error occurs. If compare is specified, you must have a start parameter.
String1 required. String expression that accepts the search.
String2 required. The string expression to search for.
Compare is optional. A numeric value indicating the type of comparison to use when evaluating substrings. For values, see the settings section. If omitted, a binary comparison is performed.
This function describes the position of a string in another string. In automated testing, it is often used as a comparison result.
If InStr(b,a)>0 Then
Msgbox “test result passed”
Msgbox “test result failed”
2. Split function
Returns a one-dimensional array based on 0 containing the specified number of substrings.
Split(expression[, delimiter[, count[, start]]])
The syntax of the split function has the following parameters:
Expression is required. A string expression that contains substrings and separators. If expression is a zero length string, split returns an empty array, that is, an array without elements and data.
Qualifier is optional. The character used to identify the bounds of a substring. If omitted, use a space (“) as the separator. If the qualifier is a zero length string, returns a single element array containing the entire expression string.
Count is optional. The number of substrings returned, – 1 indicates that all substrings are returned.
Compare is optional. A numeric value indicating the type of comparison to use when evaluating substrings. For values, see the settings section.
This function is mainly used to split strings, and it is mainly used to split test data in automatic test development.
For i=0 To Ubound(b)