-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckPoints.vbs
218 lines (195 loc) · 17.9 KB
/
CheckPoints.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Option Explicit
' search the strToSearch with thePattern, return the first matched value
Function regSearch(thePattern, strToSearch)
Dim regEx, matches
Set regEx = New RegExp
regEx.Pattern = thePattern
regEx.IgnoreCase = False
regEx.Global = false
Set matches = regEx.Execute(strToSearch)
regSearch = matches(0).Value
End Function
' assert that the expValue equals to actValue in strict(mehtod=0) or in mess(method=1)
public Function assertEqual(expValue, actValue, method)
Dim res
If method <> 0 and method <> 1 Then
msgbox "assertEqual函数的method参数不正确; 0-精确匹配, 1-模糊匹配"
Else
Select Case method
Case 0
res = (expValue = actValue)
assertEqual = res
Case 1
res = (Instr(1,expValue,actValue) + Instr(1,actValue,expValue) > 0)
assertEqual = res
Case Else
End Select
End If
End Function
' report the Test Case named tcaseWithValues as the test result is res(true for pass, false for fail)
public Function reportWithCaseName(tcaseWithValues, res)
If typename(res) = "Boolean" Then
If res Then
reporter.ReportEvent micPass, tcaseWithValues, "测试通过"
Else
reporter.ReportEvent micFail, tcaseWithValues, "测试未通过"
End If
Else
msgbox "错误的res参数("& res &"),请输入bool类型参数"
End If
End Function
'*******************************************************
'函数名:verifyDBres
'功能:根据测试结果输出标准测试报告; 无返回值
'参数:tcase,用例名称 ; res,布尔值,测试结果
'*******************************************************
public Function verifyDBvalue(expValue, DBvalue, tcase)
Dim res, tcaseWithValues
res = assertEqual(DBvalue, expValue, 0)
tcaseWithValues = tcase & vbcrlf & "期望值:" & expValue& vbcrlf & "数据库值:" & DBvalue
reportWithCaseName tcaseWithValues, res
End Function
' the basic implementation for verify*
private Function pri_verifyProperty(obj, prop, expValue, tcase, method)
Dim actValue, res, tcaseWithValues
actValue = obj.GetROProperty(prop)
res = assertEqual(expValue, actValue, method)
tcaseWithValues = tcase & vbcrlf & "期望值:" & expValue & vbcrlf & "实际值:" & actValue
reportWithCaseName tcaseWithValues, res
End Function
' public api for pri_verifyProperty
public Function verifyProperty(obj, prop, expValue, tcase, method)
pri_verifyProperty obj, prop, expValue, tcase, method
End Function
' verify the innertext property in strict
public Function verifyInnerTxt(obj, expValue, tcase)
pri_verifyProperty obj, "innertext", expValue, tcase, 0
End Function
' verify the value property in strict
public Function verifyValue(obj, expValue, tcase)
pri_verifyProperty obj, "value", expValue, tcase, 0
End Function
' verify the url property in mess
public Function verifyUrl(obj, expValue, tcase)
pri_verifyProperty obj, "url", expValue, tcase, 1
End Function
' check the display property in css. called by verifyExist
private Function pri_verifyStyleDisplay(obj, expValue, tcase)
Dim actValue, res
actValue = obj.Object.currentStyle.display
res = assertEqual(expValue, actValue, 1)
reportWithCaseName tcase, res
End Function
' verify if the obj exists. call exist(5) firstly, then verify display property in css
public Function verifyExist(obj,tcase)
If obj.exist(5) Then
pri_verifyStyleDisplay obj, "block", tcase
Exit Function
End If
reportWithCaseName tcase, false
End Function
' verify if the obj not exists. call exist(5) firstly, then verify display property in css
public Function verifyNotExist(obj,tcase)
Dim res
res = not obj.exist(5)
If res Then
reportWithCaseName tcase, res
Exit Function
Else
pri_verifyStyleDisplay obj, "none", tcase
End If
End Function
'*******************************************************
' registers
'*******************************************************
' verifyProperty
RegisterUserFunc "Browser", "verifyProperty", "verifyProperty"
RegisterUserFunc "Frame", "verifyProperty", "verifyProperty"
RegisterUserFunc "Image", "verifyProperty", "verifyProperty"
RegisterUserFunc "Link", "verifyProperty", "verifyProperty"
RegisterUserFunc "Page", "verifyProperty", "verifyProperty"
RegisterUserFunc "ViewLink", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebArea", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebButton", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebCheckBox", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebEdit", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebElement", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebFile", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebList", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebRadioGroup", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebTable", "verifyProperty", "verifyProperty"
RegisterUserFunc "WebXML", "verifyProperty", "verifyProperty"
' verifyInnerTxt
RegisterUserFunc "Browser", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "Frame", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "Image", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "Link", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "Page", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "ViewLink", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebArea", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebButton", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebCheckBox", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebEdit", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebElement", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebFile", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebList", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebRadioGroup", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebTable", "verifyInnerTxt", "verifyInnerTxt"
RegisterUserFunc "WebXML", "verifyInnerTxt", "verifyInnerTxt"
' verifyValue
RegisterUserFunc "Browser", "verifyValue", "verifyValue"
RegisterUserFunc "Frame", "verifyValue", "verifyValue"
RegisterUserFunc "Image", "verifyValue", "verifyValue"
RegisterUserFunc "Link", "verifyValue", "verifyValue"
RegisterUserFunc "Page", "verifyValue", "verifyValue"
RegisterUserFunc "ViewLink", "verifyValue", "verifyValue"
RegisterUserFunc "WebArea", "verifyValue", "verifyValue"
RegisterUserFunc "WebButton", "verifyValue", "verifyValue"
RegisterUserFunc "WebCheckBox", "verifyValue", "verifyValue"
RegisterUserFunc "WebEdit", "verifyValue", "verifyValue"
RegisterUserFunc "WebElement", "verifyValue", "verifyValue"
RegisterUserFunc "WebFile", "verifyValue", "verifyValue"
RegisterUserFunc "WebList", "verifyValue", "verifyValue"
RegisterUserFunc "WebRadioGroup", "verifyValue", "verifyValue"
RegisterUserFunc "WebTable", "verifyValue", "verifyValue"
RegisterUserFunc "WebXML", "verifyValue", "verifyValue"
' verifyUrl
RegisterUserFunc "Frame", "verifyUrl", "verifyUrl"
RegisterUserFunc "Image", "verifyUrl", "verifyUrl"
RegisterUserFunc "Link", "verifyUrl", "verifyUrl"
RegisterUserFunc "Page", "verifyUrl", "verifyUrl"
RegisterUserFunc "WebArea", "verifyUrl", "verifyUrl"
'verifyExist
RegisterUserFunc "Browser", "verifyExist", "verifyExist"
RegisterUserFunc "Frame", "verifyExist", "verifyExist"
RegisterUserFunc "Image", "verifyExist", "verifyExist"
RegisterUserFunc "Link", "verifyExist", "verifyExist"
RegisterUserFunc "Page", "verifyExist", "verifyExist"
RegisterUserFunc "ViewLink", "verifyExist", "verifyExist"
RegisterUserFunc "WebArea", "verifyExist", "verifyExist"
RegisterUserFunc "WebButton", "verifyExist", "verifyExist"
RegisterUserFunc "WebCheckBox", "verifyExist", "verifyExist"
RegisterUserFunc "WebEdit", "verifyExist", "verifyExist"
RegisterUserFunc "WebElement", "verifyExist", "verifyExist"
RegisterUserFunc "WebFile", "verifyExist", "verifyExist"
RegisterUserFunc "WebList", "verifyExist", "verifyExist"
RegisterUserFunc "WebRadioGroup", "verifyExist", "verifyExist"
RegisterUserFunc "WebTable", "verifyExist", "verifyExist"
RegisterUserFunc "WebXML", "verifyExist", "verifyExist"
'verifyNotExist
RegisterUserFunc "Browser", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "Frame", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "Image", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "Link", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "Page", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "ViewLink", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebArea", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebButton", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebCheckBox", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebEdit", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebElement", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebFile", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebList", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebRadioGroup", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebTable", "verifyNotExist", "verifyNotExist"
RegisterUserFunc "WebXML", "verifyNotExist", "verifyNotExist"