-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions.qfl
485 lines (436 loc) · 35.2 KB
/
Functions.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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
Public iTestID
Public strEntityType
Public strEntityCategory
Public strProcessType
Public blnAmend
Public blnReactivate
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Function Logon(strURL, strUserId, strPassword)
' Open the browser
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe", strURL, "Z:\", "open"
' See if it's opened correctly
Browser("Browser").Sync
' Enter User Id and password
Browser("Browser").Page("Logon Page").WebEdit("User Name").Set strUserId
Browser("Browser").Page("Logon Page").WebEdit("Password").Set strPassword
' Click on Login
Browser("Browser").Page("Logon Page").WebButton("Log In").Click
' See if we get any errors
If Browser("Browser").Page("Logon Page").WebElement("Security Access Error:").Exist(5) Then
Reporter.ReportEvent micFail, "Failed To Login", "Message [" & Browser("Browser").Page("Logon Page").WebElement("Login Error Message").GetROProperty("innerText") & "] given. Aborting..."
Logon = "Fail"
Else
Reporter.ReportEvent micPass, "Logged in", "Logged in correctly"
Logon = "Pass"
End If
End Function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Function RandomString(iLen, strAlphaOrNumeric)
Dim str
Dim iRnd
Const LETTERS = "abcdefghijklmnopqrstuvwxyz"
Const NUMBERS = "0123456789"
Const BOTH = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"
Randomize
Select Case strAlphaOrNumeric
Case "Alpha"
For i = 1 To iLen
iRnd = Int((Len(LETTERS) - 1 + 1) * Rnd + 1)
str = str & Mid(LETTERS, iRnd, 1)
Next
RandomString = str
Case "Numeric"
For i = 1 To iLen
iRnd = Int((Len(NUMBERS) - 1 + 1) * Rnd + 1)
str = str & Mid(NUMBERS, iRnd, 1)
Next
RandomString = str
Case Else
For i = 1 To iLen
iRnd = Int((Len(BOTH) - 1 + 1) * Rnd + 1)
str = str & Mid(BOTH, iRnd, 1)
Next
RandomString = str
End Select
End Function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Function StartReporting(strDetails)
Reporter.StartReporting strDetails, ""
End Function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Function EndReporting
Reporter.EndReporting
End Function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Sub ExpandAll()
Dim objDesc, objChildren, objChild
On Error Resume Next
Set objDesc = Description.Create
objDesc("micclass").Value = "WebElement"
objDesc("html tag").Value = "TD"
objDesc("class").Value = "titleBarIconCollapsed"
Set objChildren = Browser("Browser").Page("Process Work").Frame("RoomPane").ChildObjects(objDesc)
For i = 0 To objChildren.Count -1
Set objChild = objChildren.Item(i)
objChild.Highlight
objChild.Click
Wait 1
Next
Set objChild = Nothing
Set objChildren = Nothing
Set objDesc = Nothing
On Error GoTo 0
End Sub
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Sub AddNewVendorRow()
Dim objDesc, objButtons
Set objDesc = Description.Create
objDesc("micclass").Value = "WebButton"
objDesc("html tag").Value = "BUTTON"
objDesc("html id").Value = "RLAdd"
objDesc("outerhtml").Value = ".*Vendors.*"
Set objButtons = Browser("Browser").Page("Process Work").Frame("RoomPane").ChildObjects(objDesc)
objButtons.Item(0).Click
Wait 1
Set objButtons = Nothing
Set objDesc = Nothing
End Sub
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Function HowManyVendors()
Dim objDesc, objLists
Set objDesc = Description.Create
objDesc("micclass").Value = "WebList"
objDesc("html tag").Value = "SELECT"
objDesc("name").Value = ".*Vendors.*VendorCode"
Set objLists = Browser("Browser").Page("Process Work").Frame("RoomPane").ChildObjects(objDesc)
HowManyVendors = objLists.Count
Set objLists = Nothing
Set objDesc = Nothing
End Function
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Sub CheckPartyValue(strField, strValue)
Dim thisTable
Dim iRow
Dim iCol
Dim iTblRows
Dim a, b
' Set the table
Set thisTable = WebTable.SetObject("innertext:=First NameLast NameDepartmentEmailPhone.*|column names:=;First Name;;Last Name;;;;Department;;Email;;Phone;;Department Email;;")
' See which Row we're dealing with
a = Instr(1, strField, "2")
b = Instr(1, strField, "3")
If (a = 0) And (b = 0) Then
iRow = 2
End If
If (a > 0) And (b = 0) Then
iRow = 3
End If
If (a = 0) And (b > 0) Then
iRow = 4
End If
' See which column we're dealing with
If Instr(1, strField, "Department") Then
iCol = 8
End If
If Instr(1, strField, "Email") Then
iCol = 10
End If
If Instr(1, strField, "Phone") Then
iCol = 12
End If
' Get the number of table rows
iTblRows = thisTable.RowCount
' Get the value from the row and col
strActValue = Trim(thisTable.GetCellData(iRow, iCol))
If strActValue <> strValue Then
Reporter.ReportEvent micFail, "[" & strField & "] value not correct.", "Expected [" & strValue & "] but found [" & strActValue & "]. Please check application."
Else
Reporter.ReportEvent micPass, "[" & strField & "] value found", "Expected value found."
End If
Set thisTable = Nothing
End Sub
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Sub GetPartyFromList(strSearchCriteria)
Dim strFirst, strLast
Dim thisTable
' Split the search criteria
splitSearch = Split(strSearchCriteria, "|")
' Make sure our table exists
If Not WebTable.Exist("Results", 2) Then
Reporter.ReportEvent micWarning, "Results table not present", "The results from the initial search did not bring back a results table. Entering search criteria again."
WebEdit.SetText "First Name", splitSearch(0)
WebEdit.SetText "Last Name", splitSearch(1)
WebButton.Click "Search"
If Not WebTable.Exist("Results", 2) Then
Reporter.ReportEvent micWarning, "Results table not present", "The results from the secondary search did not bring back a results table. Please check application."
WebButton.Click "Cancel"
Exit Sub
End If
End If
' Get the table and work around until you find the correct row
Set thisTable = WebTable.SetObject("Results")
iRows = thisTable.RowCount
For i = 1 To iRows
If Trim(thisTable.GetCellData(i, 1)) = UCase(splitSearch(0)) And Trim(thisTable.GetCellData(i, 2)) = UCase(splitSearch(1)) Then
Set objEle = thisTable.ChildItem(i, 1, "WebElement", 0)
objEle.Click
Wait 1
Exit For
End If
Next
' Click on Select
Do While WebButton.GetROProperty("Select", "disabled") = 1
Wait 1
iCount = iCount + 1
If iCount > 10 Then
Exit Do
End If
Loop
If WebButton.GetROProperty("Select", "disabled") = 1 Then
Reporter.ReportEvent micFail, "Selected [" & splitSearch(0) & " - " & splitSearch(1) & "]", "The [Select] button is not enabled after selecting the item in the table. Please check application."
WebButton.Click "Cancel"
Set thisTable = Nothing
Exit Sub
Else
WebButton.Click "Select"
Wait 1
End If
' Make sure the window has closed
If GenericObject.Exist("Party Search", 5) Then
Reporter.ReportEvent micFail, "Selected [" & splitSearch(0) & " - " & splitSearch(1) & "]","The 'Party Search' window is still displayed. Please check application."
Else
Reporter.ReportEvent micPass, "Selected [" & splitSearch(0) & " - " & splitSearch(1) & "]", "The party was selected."
End If
Set thisTable = Nothing
End Sub
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Function DeleteRow(strLocation, iRow)
Dim objTableDesc, objIconDesc
Dim objTable, objIcon
Dim blnVendor
' Set up the table identifier
Set objTableDesc = Description.Create
objTableDesc("micclass").Value = "WebTable"
Select Case strLocation
Case "Name Type"
strLocation = "Alternate Name"
Case "Email Address Type"
strLocation = "Email Address"
Case "Website Address Type"
strLocation = "Website Address"
Case "Number Type"
strLocation = "Telephone Detail"
Case "Government ID Type"
strLocation = "Government Identifier"
Case "Alternate System ID Type"
strLocation = "Alternate Identifier"
Case "Address Type"
strLocation = "Address Details"
Case "Vendor"
blnVendor = True
End Select
If blnVendor = True Then
objTableDesc("class").Value = "repeatReadWrite"
objTableDesc("column names").Value = "VendorPlease.*"
Else
objTableDesc("outertext").Value = strLocation & ".*"
End If
' Set up the icon identifier
If blnVendor = False Then
Set objIconDesc = Description.Create
objIconDesc("micclass").Value = "WebButton"
objIconDesc("class").Value = "iconDelete.*"
If strLocation <> "Address Details" Then
objIconDesc("outerhtml").Value = ".*Delete this row " & iRow & ".*"
End If
Else
Set objIconDesc = Description.Create
objIconDesc("micclass").Value = "Image"
objIconDesc("alt").Value = "Delete"
'objIconDesc("fine name").Value = "trash_on.gif"
'objIconDesc("html tag").Value = "IMG"
End If
' Get the table
Set objTable = GenericObject.ChildObjects("RoomPane", objTableDesc)
If objTable.Count = 0 Then
Reporter.ReportEvent micFail, "Delete Row","The table passed in that contains the rows to delete could not be found, please check."
Exit Function
End If
' Get the icon
Set objIcon = objTable.Item(0).ChildObjects(objIconDesc)
If strLocation <> "Address Details" Then
If objIcon.Count = 0 Then
Reporter.ReportEvent micFail, "Delete Row", "The icon at row [" & iRow & "] could not be found. Please check data."
Exit Function
Else
If blnVendor = False Then
' Click on icon
objIcon.Item(0).Click
Wait 2
Else
objIcon.Item(iRow -1).Highlight
objIcon.Item(iRow -1).Click
End If
End If
Else
For i = 0 To objIcon.Count -1
Set objThis = objIcon.Item(i).object
iStart = Instr(1, objThis.outerhtml, "deleteAddress")
If iStart <> 0 Then
' Find (" then ")
iNewStart = Instr(iStart, objThis.outerhtml, "(")
iNewEnd = Instr(iStart, objThis.outerhtml, ",")
' Get the value between the braces
iValue = Replace(Mid(objThis.outerhtml, iNewStart + 1, ((iNewEnd -1) - iNewStart)),Chr(34), "")
If CInt(iValue) = Cint(iRow + 1) Then
objIcon.Item(i).Click
Wait 2
GenericObject.HandlePopUp "OK"
Exit For
End If
End If
Next
End If
' Destroy objects
Set objIcon = Nothing
Set objTable = Nothing
Set objIconDesc = Nothing
Set objTableDesc = Nothing
blnVendor = False
End Function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Function MergeArrays(arr1, arr2)
Dim arrTemp()
Dim iBound1, iBound2
On Error Resume Next
If IsArrayDimmed(arr1) Then
iBound1 = UBound(arr1)
Else
MergeArrays = arr2
Exit Function
End If
If IsArrayDimmed(arr2) Then
iBound2 = UBound(arr2)
Else
MergeArrays = arr1
Exit Function
End If
If Err Then
Err.Clear
On Error GoTo 0
Exit Function
End If
If iBound1 = iBound2 Then
For i = 0 To UBound(arr1)
arr1Split = Split(arr1(i), "|")
arr2Split = Split(arr2(i), "|")
For j = 0 To UBound(arr1Split)
arr1Next = Split(arr1Split(j), ",")
arr2Next = Split(arr2Split(j), ",")
If arr2Next(1) = "" Then
strData = strData & "|" & arr1Next(0) & "," & arr1Next(1)
Else
strData = strData & "|" & arr1Next(0) & "," & arr2Next(1)
End If
Next
strData = Mid(strData, 2)
ReDim Preserve arrTemp(i)
arrTemp(i) = strData
strData = ""
Next
End If
If iBound1 > iBound2 Then
ReDim Preserve arrTemp(iBound1)
For i = 0 To UBound(arr1)
arr1Split = Split(arr1(i), "|")
arr2Split = Split(arr2(i), "|")
a = Mid(arr1Split(0), 1, 7)
b = Mid(arr2Split(0), 1, 7)
If InStr(1, a, "Count") Then
If a = b Then
For j = 0 To UBound(arr1Split)
arr1Next = Split(arr1Split(j), ",")
arr2Next = Split(arr2Split(j), ",")
If arr2Next(1) = "" Then
strData = strData & "|" & arr1Next(0) & "," & arr1Next(1)
Else
strData = strData & "|" & arr1Next(0) & "," & arr2Next(1)
End If
Next
strData = Mid(strData, 2)
ReDim Preserve arrTemp(i)
iTempBound = UBound(arrTemp)
arrTemp(i) = strData
strData = ""
Else
ReDim Preserve arrTemp(i)
arrTemp(i) = arr1(i)
End If
Else
For j = 0 To UBound(arr1Split)
arr1Next = Split(arr1Split(j), ",")
arr2Next = Split(arr2Split(j), ",")
If arr2Next(1) = "" Then
strData = strData & "|" & arr1Next(0) & "," & arr1Next(1)
Else
strData = strData & "|" & arr1Next(0) & "," & arr2Next(1)
End If
Next
strData = Mid(strData, 2)
ReDim Preserve arrTemp(i)
iTempBound = UBound(arrTemp)
arrTemp(i) = strData
strData = ""
End If
Next
End If
If iBound1 < iBound2 Then
For i = 0 To UBound(arr1)
arr1Split = Split(arr1(i), "|")
arr2Split = Split(arr2(i), "|")
For j = 0 To UBound(arr1Split)
arr1Next = Split(arr1Split(j), ",")
arr2Next = Split(arr2Split(j), ",")
If arr2Next(1) = "" Then
strData = strData & "|" & arr1Next(0) & "," & arr1Next(1)
Else
strData = strData & "|" & arr1Next(0) & "," & arr2Next(1)
End If
Next
strData = Mid(strData, 2)
ReDim Preserve arrTemp(i)
arrTemp(i) = strData
strData = ""
Next
ReDim Preserve arrTemp(iBound2)
arrTemp(iBound2) = arr2(iBound2)
End If
For i = 0 To UBound(arrTemp)
If InStr(1, arrTemp(i), "Delete") Then
arrTemp = DeleteArrayItem(arrTemp, i)
End If
Next
MergeArrays = arrTemp
On Error GoTo 0
End Function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Function IsArrayDimmed(arr)
IsArrayDimmed = False
If IsArray(arr) Then
On Error Resume Next
Dim ub : ub = UBound(arr)
If (Err.Number = 0) And (ub >= 0) Then IsArrayDimmed = True
End If
End Function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
Public Function DeleteArrayItem(theArray, theElement)
Dim i
If theElement < LBound(theArray) Or theElement > UBound(theArray) Then
Exit Function
End If
For iLoop = theElement to UBound(theArray) - 1
theArray(iLoop) = theArray(iLoop + 1)
Next
Redim Preserve theArray(UBound(theArray) - 1)
DeleteArrayItem = theArray
End Function