Analysis of methods for developing automated test scripts in VBScript _vbs

Source: Internet
Author: User
Tags numeric numeric value

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.