-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcls_Validation_Class.qfl
405 lines (370 loc) · 33.2 KB
/
cls_Validation_Class.qfl
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
Public Validation
Set Validation = ValidationInstance
'--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Class clsValidation
'------------------------------------------------------------------------------------------------------------------
Private Sub Class_Initialize
End Sub
'------------------------------------------------------------------------------------------------------------------
Public Sub ValidateExchange(strDB)
Dim objRS
Dim dictCountries
Dim iHeader
Dim blnCorrect
iHeader = 1
iRow = 2
' See if we're already connected to the database
If DB.Connected(strDB) = False Then
' Declarations
DB.ConnectToDB strDB
End If
Set dictCountries = CreateObject("Scripting.Dictionary")
Set objRS = DB.ReturnRecordSet("select * from Exchanges_A_to_J")
iColumns = objRS.Fields.Count
For n = 0 To iColumns - 1
strCountry = objRS.Fields(n).Name
objRS.MoveFirst
If dictCountries.Exists(strCountry) = False Then
Do While Not objRS.EOF
If objRS.Fields(n).Value <> "" Then
strExchange = strExchange & ";" & objRS.Fields(n).Value
Else
Exit Do
End If
objRS.MoveNext
Loop
strExchange = Mid(strExchange, 2)
dictCountries.Add strCountry, strExchange
strExchange = ""
End If
Next
Set objRS = DB.ReturnRecordSet("select * from Exchanges_K_to_Z")
iColumns = objRS.Fields.Count
For n = 0 To iColumns - 1
strCountry = objRS.Fields(n).Name
objRS.MoveFirst
If dictCountries.Exists(strCountry) = False Then
Do While Not objRS.EOF
If objRS.Fields(n).Value <> "" Then
strExchange = strExchange & ";" & objRS.Fields(n).Value
End If
objRS.MoveNext
Loop
strExchange = Mid(strExchange, 2)
dictCountries.Add strCountry, strExchange
strExchange = ""
End If
Next
' Start reporting
Reporter.StartReporting "Validation of Exchanges Start", ""
' Do basic search
WebButton.Click "New EM Request"
GenericObject.HandlePopUp "OK"
WebList.SelectItem "Search Entity Category", "Non-Individual"
WebList.SelectItem "Search Entity Type", "Organisation"
WebList.SelectItem "Search By","GRID"
WebEdit.SetText "Search GRID", "1"
WebButton.Click "Search"
GenericObject.HandlePopUp "OK"
' Now create
WebButton.Click "Create Entity"
GenericObject.HandlePopUp "OK"
' Fill in mandatory fields
WebList.SelectItem "Legal Entity", "Not Applicable"
WebList.SelectItem "Requestor Location", "United Kingdom"
WebEdit.SetText "Legal Name", "MGB Trial Exchange 001"
WebList.SelectItem "Country of Incorporation", "United Kingdom"
WebList.SelectItem "Country Of Primary Operation", "Albania"
iNoCountries = WebList.GetROProperty("Exchange Country","items count")
For i = 1 To iNoCountries -1
blnCorrect = True
WebList.SelectItem "Exchange Country", "#" & i
strCountry = WebList.GetROProperty("Exchange Country", "selection")
If dictCountries.Exists(strCountry) Then
Do
rc = WebList.GetROProperty("Exchange", "disabled")
Loop While rc = 1
WebList.Click "Exchange"
WebList.Init "Exchange"
strActExchanges = WebList.GetROProperty("Exchange", "all items")
strActExchanges = Replace(strActExchanges, "Please Select...;", "")
strActExchangesNoSpace = Replace(strActExchanges, " ", "")
strExpExchanges = dictCountries(strCountry)
strExpExchangesNoSpace = Replace(strExpExchanges, " ", "")
If strActExchangesNoSpace <> strExpExchangesNoSpace Then
splitAct = Split(strActExchanges, ";")
splitExp = Split(strExpExchanges, ";")
If UBound(splitAct) = 0 Then
WebList.Init "Exchange"
strActExchanges = WebList.GetROProperty("Exchange", "all items")
strActExchanges = Replace(strActExchanges, "Please Select...;", "")
splitAct = Split(strActExchanges, ";")
End If
If Ubound(splitAct) <> Ubound(splitExp) Then
Reporter.ReportEvent micFail, "Different number of Exchanges", "Different number of Exchanges, expected [" & Ubound(splitExp) & "] but found [" & Ubound(splitAct) & "]. Please check."
End If
On Error Resume Next
For j = 0 To UBound(splitExp)
If Instr(1, strActExchanges, Trim(splitExp(j))) Then
blnFound = True
End If
If blnFound = True Then
blnFound = False
Else
Reporter.ReportEvent micFail, "Country - " & strCountry & ", Exchange missing","Expected Exchange ["& splitExp(j) & "] not found in actual list"
blnCorrect = False
End If
Next
For j = 0 To UBound(splitAct)
If Instr(1, strExpExchanges, Trim(splitAct(j))) Then
blnFound = True
End If
If blnFound = True Then
blnFound = False
Else
Reporter.ReportEvent micFail, "Country - " & strCountry & ", Exchange missing","Actual Exchange ["& splitAct(j) & "] not found in expected list"
blnCorrect = False
End If
Next
Else
blnCorrect = True
End If
Else
Reporter.ReportEvent micFail, "Unexpected Country", "Country [" & strCountry & "] was found in the application but is not on the reference data. Please check."
blnCorrect = False
End If
If blnCorrect = True Then
Reporter.ReportEvent micPass, "[" & strCountry & "] - All Exchanges Correct", "All Exchanges for Country [" & strCountry & "] are correct."
End If
Next
' End reporting
Reporter.EndReporting
On Error GoTo 0
Set dictCountries = Nothing
Set objRS = Nothing
End Sub
'------------------------------------------------------------------------------------------------------------------
Public Sub ValidateSearch(strDB)
' See if we're already connected to the database
If DB.Connected(strDB) = False Then
' Declarations
DB.ConnectToDB strDB
End If
' Get to the search screen
WebButton.Click "New EM Request"
GenericObject.HandlePopUp "OK"
' Check correct values in list
VerifyList "Entity_Category"
WebList.SelectItem "Search Entity Category", "Non-Individual"
VerifyList "Entity_Type"
VerifyList "By"
VerifyList "Country_Of_Incorporation"
VerifyList "Entity_Status"
WebList.SelectItem "Search By", "Government ID"
VerifyList "Government_ID_Type"
WebList.SelectItem "Search By", "Cross Reference ID"
VerifyList "Cross_Reference_ID_Type"
WebList.SelectItem "Search Entity Category", "Individual"
VerifyList "Country_Of_Residence"
' Check correct fields displayed when items selected
WebList.SelectItem "Search Entity Category", "Individual"
WebList.SelectItem "Search By", "GRID"
CheckField "GRID", "WebEdit", "", "Value cannot be blank"
WebList.SelectItem "Search By", "Name"
CheckField "First Name", "WebEdit", "", ""
CheckField "Middle Name", "Web Edit", "", ""
CheckField "Last Name", "Web Edit", "", "Value cannot be blank"
CheckField "Include Alternate Names in Search", "WebCheckBox", "", ""
CheckField "Include Former Names in Search", "WebCheckBox", "", ""
CheckField "Data Verification Status", "WebCheckBox", "", ""
CheckField "Select all", "WebButton", "", ""
WebCheckBox.Tick "Include Alternate Names in Search", "OFF"
CheckField "First Name", "WebEdit", "", "Value cannot be blank"
CheckField "Middle Name", "Web Edit", "", ""
CheckField "Last Name", "Web Edit", "", "Value cannot be blank"
WebList.SelectItem "Search By", "Government ID"
CheckField "Search Government ID Type", "WebList", "", "Value cannot be blank"
CheckField "Search Government ID", "WebEdit", "", "Value cannot be blank"
WebList.SelectItem "Search By", "Cross Reference ID"
CheckField "Search Cross Reference ID Type", "WebList", "", "Value cannot be blank"
CheckField "Search Cross Reference ID", "WebEdit", "", "Value cannot be blank"
WebList.SelectItem "Search Entity Category", "Non-Individual"
WebList.SelectItem "Search By", "GRID"
CheckField "GRID", "WebEdit", "", "Value cannot be blank"
WebList.SelectItem "Search By", "Name"
CheckField "Legal Name", "WebEdit", "", ""
CheckField "Include Alternate Names in Search", "WebCheckBox", "", ""
CheckField "Include Former Names in Search", "WebCheckBox", "", ""
CheckField "Data Verification Status", "WebCheckBox", "", ""
CheckField "Select all", "WebButton", "", ""
WebList.SelectItem "Search By", "Government ID"
CheckField "Search Government ID Type", "WebList", "", "Value cannot be blank"
CheckField "Search Government ID", "WebEdit", "", "Value cannot be blank"
WebList.SelectItem "Search By", "Cross Reference ID"
CheckField "Search Cross Reference ID Type", "WebList", "", "Value cannot be blank"
CheckField "Search Cross Reference ID", "WebEdit", "", "Value cannot be blank"
' Check correct error message displayed when invalid entry
WebList.SelectItem "Search Entity Category", "Individual"
WebList.SelectItem "Search By", "GRID"
CheckField "GRID", "WebEdit", "alpha", "Non numeric value is not accepted"
WebList.SelectItem "Search By", "Cross Reference ID"
WebList.SelectItem "Search Cross Reference ID Type", "CBID"
CheckField "Search Cross Reference ID", "WebEdit", "aa", "** Please enter min 4 and max 8 characters only."
CheckField "Search Cross Reference ID", "WebEdit", "0123456789", "** Please enter min 4 and max 8 characters only."
WebList.SelectItem "Search Cross Reference ID Type", "CDU/CIN"
CheckField "Search Cross Reference ID", "WebEdit", "01234567890123456789", "** Please enter max 10 characters only."
CheckField "Search Cross Reference ID", "WebEdit", "aaa", "Non numeric value is not accepted"
WebList.SelectItem "Search Cross Reference ID Type", "SWIFT/BIC"
CheckField "Search Cross Reference ID", "WebEdit", "012345678901234567890", "** Please enter 8 or 11 characters."
CheckField "Search Cross Reference ID", "WebEdit", "abcdshdgfk", "** Please enter 8 or 11 characters."
End Sub
'------------------------------------------------------------------------------------------------------------------
Private Sub VerifyList(strListName)
Dim dictValues
Dim objRS
Dim iNoItems
Dim strFoundItem
Dim blnFound
blnFound = True
' Set up the dictionary that will hold the values
Set dictValues = CreateObject("Scripting.Dictionary")
' See if we're doing countries
If Instr(1, strListName, "Country") Then
Set objRS = DB.ReturnRecordSet("Select Countries From Reference_Data")
ElseIf strListName = "By" Then
Set objRS = DB.ReturnRecordSet("Select Search_By From Reference_Data")
Else
Set objRS = DB.ReturnRecordSet("Select " & strListName & " From Reference_Data")
End If
' Check Entity Categories
Do While Not objRS.EOF
If objRS.Fields(0).Value <> "" Then
dictValues.Add objRS.Fields(0).Value, 0
End If
objRS.MoveNext
Loop
strListName = Replace(strListName, "_", " ")
WebList.WaitProperty "Search " & strListName, "disabled", 0, 12000
iNoItems = WebList.GetROProperty("Search " & strListName, "items count")
For i = 1 To iNoItems
strFoundItem = Trim(WebList.GetItem("Search " & strListName, i))
If Instr(1, strFoundItem, "Please Select") = 0 Then
' See if this is found in our dictionary
If dictValues.Exists(strFoundItem) = True Then
dictValues.Item(strFoundItem) = 1
Else
Reporter.ReportEvent micWarning, "VerifyList [ " & strListName & " ]", "The dropdown list labelled [" & strListName & "] contains the option [" & strFoundItem & "]. This option has not been passed as a valid option for this list. Please check application"
End If
End If
Next
' Put dictionary items into arrays
arrKeys = dictValues.Keys
arrItems = dictValues.Items
' Loop round the dictionary and see if we've got all 1's or still 0's
For i = 0 To UBound(arrKeys)
If arrItems(i) = 0 Then
If Instr(1, arrKeys(i), "Please Select") = 0 Then
Reporter.ReportEvent micFail, "VerifyList [ " & strListName & " ]", "Option [" & arrKeys(i) & "] was NOT found in the [" & strListName & "] dropdown list."
blnFound = False
End If
End If
Next
If blnFound = True Then
Reporter.ReportEvent micPass, "VerifyList [ " & strListName & " ]", "All the expected items in the [" & strListName & "] dropdown list are present."
End If
End Sub
'------------------------------------------------------------------------------------------------------------------
Private Sub CheckField(strFieldName, strFieldType, strEnterValue, strErrorMsg)
Dim objDesc, objElements, objElement
Dim blnFound
Dim iFound, iExpFound
iFound = 0
' Check to see if the field exists
Select Case strFieldType
Case "WebEdit"
If WebEdit.Exist("Search " & strFieldName, 5) Then
Reporter.ReportEvent micPass, "Check Field Success", "Field [ " & strFieldName & " ] found on screen."
Else
Reporter.ReportEvent micFail, "Check Field Failure", "Field [" & strFieldName & " ] NOT found on screen, please check."
End If
If strEnterValue <> "" Then
WebEdit.SetText "Search " & strFieldName, strEnterValue
End If
Case "WebList"
If WebList.Exist("Search " & strFieldName, 5) Then
Reporter.ReportEvent micPass, "Check Field Success", "Field [ " & strFieldName & " ] found on screen."
Else
Reporter.ReportEvent micFail, "Check Field Failure", "Field [" & strFieldName & " ] NOT found on screen, please check."
End If
If strEnterValue <> "" Then
WebList.SelectItem "Search " & strFieldName, strEnterValue
End If
Case "WebCheckBox"
If WebCheckBox.Exist(strFieldName, 5) Then
Reporter.ReportEvent micPass, "Check Field Success", "Field [ " & strFieldName & " ] found on screen."
Else
Reporter.ReportEvent micFail, "Check Field Failure", "Field [" & strFieldName & " ] NOT found on screen, please check."
End If
If strEnterValue <> "" Then
WebCheckBox.Tick strFieldName, strEnterValue
End If
Case "WebButton"
If WebButton.Exist(strFieldName, 5) Then
Reporter.ReportEvent micPass, "Check Field Success", "Field [ " & strFieldName & " ] found on screen."
Else
Reporter.ReportEvent micFail, "Check Field Failure", "Field [" & strFieldName & " ] NOT found on screen, please check."
End If
End Select
' Press Search button
WebButton.Click "Search"
' Now check for error message if required
If strErrorMsg <> "" Then
Set objDesc = Description.Create
objDesc("micclass").Value = "WebElement"
objDesc("class").Value = "iconError"
objDesc("html id").Value = "PegaRULESErrorFlag"
objDesc("html tag").Value = "SPAN"
Set objElements = GenericObject.ChildObjects("RoomPane_Search", objDesc)
For i = 0 To objElements.Count -1
Set objElement = objElements.Item(i)
strActVal = objElement.GetROProperty("outerhtml")
' See if we've got more than one to check
If Instr(1, strErrorMsg, ";") Then
thisSplit = Split(strErrorMsg, ";")
iExpFound = Ubound(thisSplit)
For Each ele In thisSplit
If Instr(1, strActVal, ele) Then
iFound = iFound + 1
End If
Next
If iExpFound = iFound Then
blnFound = True
End If
Else
If Instr(1, strActVal, strErrorMsg) Then
blnFound = True
Exit For
End If
End If
Next
If blnFound = True Then
Reporter.ReportEvent micPass, "Check Field Success", "Error message [ " & strErrorMsg & " ] found on screen."
Else
Reporter.ReportEvent micFail, "Check Field Failure", "Error message [ " & strErrorMsg & " ] NOT found on screen, please check."
End If
End If
End Sub
'------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------
Private Sub Class_Terminate
End Sub
End Class
'------------------------------------------------------------------------------------------------------------------
Public Function ValidationInstance()
Set ValidationInstance = New clsValidation
End Function