Analysis on methods for developing automated test scripts using VBScript

Source: Internet
Author: User

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

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.