utility

Option Explicit


'DESCRIPTION
' Utility functions
' A set of functions which you can use whole application.

Function Login (user, password)
dim url_to_use, ret
Select Case URL_FLAG
Case "CORE"
url_to_use = CORE_APPLICATION_URL
Case "PMBI"
url_to_use = PMBI_CONFIGURATION_APPLICATION_URL
Case "BI"
url_to_use = BI_APPLICATION_URL
Case "SP"
url_to_use = SP_APPLICATION_URL
End Select
Call Close_All_Browsers ' Login will be used as recovery scenario.
Call Open_URL(url_to_use)
Call Set_Window(1)
Call Set_TextField("username", 0, user)
Call Set_TextField("password", 0, password)
Click_Button "OK",0
' verification Login went through:
Select Case URL_FLAG ' 02/16/05, Max: using Verify_ functions to fail scripts if Login failed.
Case "CORE"
ret = Link_Exists("Options",0)
Case "PMBI"
Call Set_Window(2)
ret = Link_Exists("Edit",0)
Case "BI"
Call Set_Window(2)
ret = Link_Exists("User Guide",0)
Case "SP"
Call Set_Window(2)
ret = Link_Exists("New...",0)
End Select
Login = ret
' this function should contain more code. i want to be able to pass/fail function based on what i want.
' one day i want to use it to verify login failed, another day i want to use it to verify login passed.
End Function

Function Verify_Login_Pass(user, password)
if Login (user, password) then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_Login_Pass", _
"Login Successful : username: " & user & " password: " & password
Verify_Login_Pass = PASS
Else
Call REPORT_FAILURE2("Verify_Login_Pass", _
"Login Fail : username: " & user & " password: " & password)

Verify_Login_Pass = FAIL
end if
End Function

Function Verify_Login_Fail(user, password)
if Login (user, password) then
Call REPORT_FAILURE2("Verify_Login_Fail", _
"Login Successful : username: " & user & " password: " & password)

Verify_Login_Fail = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_Login_Fail", _
"Login Fail : username: " & user & " password: " & password
Verify_Login_Fail = PASS
end if
End Function

'OPEN_ISSUE **************************
' Need to separate into Set_DataPicker and Set_Picker
'OPEN_ISSUE **************************
'Set a value specified into Picker value such as:
' IN filed for Resource Finder
' User Defined Classification
' Pool Picker, Organization Picker
'Control between Tree View and List View
'Basically, go to List View and put the specified value onto Search field.
'Can not see root value (ex: "Enterprise") in List View.
'In this particular case, have to go to Tree View, or take it from drop-down
Function Set_Picker(pStrPickerImageAltText, pStrPickerComboboxName, pIntIndex, pStrItemName)
Call FUNCTION_START("Set_Picker")
' check that there is the item name on the actual combobox list
' If so, no need to click on Picker image
If ComboBoxItem_Exists_ByName(pStrPickerComboboxName, 0, pStrItemName) Then
Call Set_ComboBoxItem_ByName (pStrPickerComboboxName, 0, pStrItemName)
Set_Picker = PASS
Call FUNCTION_END("Set_Picker. First END point")
Exit Function
End If

If Click_Image(pStrPickerImageAltText, pIntIndex) <> PASS then
Set_Picker = FAIL
Call FUNCTION_END("Set_Picker. Eight END point")
Call CaptureWindowImage("Set_Picker Couldn't click image '" & pStrPickerImageAltText & "'")
Exit Function
End If

'If the picker page you open is List View/Tree View type page, you need to open List View.
If Link_Exists("List View", 0) Then
Call Click_Link ("List View", 0)
End If

'When you open a picker page, you might have already seen the link you need to click
If Link_Exists(pStrItemName, 0) Then
Call Click_Link(pStrItemName, 0)
Set_Picker = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageAltText & "'")
'msgBox "line 65"
Call FUNCTION_END("Set_Picker. Second END point")
Exit Function 'Max, 12/28/04
End If

'This code is for Assigned Resource of Risk and Issues
If ComboBox_Exists("obj_ResourceFinderProjectMembersDelegate_filterEntry", 0) Then
Call Set_ComboBoxItem_ByName ("obj_ResourceFinderProjectMembersDelegate_filterEntry", 0, "Active Resources")
End If

'This is for selecting Parent Project
If ComboBox_Exists("obj_ParentProjectListFinderDelegate_filterEntry", 0) Then
Call Set_ComboBoxItem_ByName ("obj_ParentProjectListFinderDelegate_filterEntry", 0, "All Projects")
End If

'This is for selecting Project in Third-Party T&E New Time
If ComboBox_Exists("obj_TransactionProjectListFinderDelegate_filterEntry", 0) Then
Call Set_ComboBoxItem_ByName ("obj_TransactionProjectListFinderDelegate_filterEntry", 0, "All Projects")
End If

' 01/18/05, Max: this does not work if List View needs to be clicked because if we click link, what is the next step? <-- this is something Irina complained before as well
Call Set_TextField_ByIndex (0, pStrItemName)
Call Click_Link("Find",0)

If Link_Exists(pStrItemName, 0) Then
Call Click_Link(pStrItemName, 0)
Set_Picker = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageAltText & "'")
Call FUNCTION_END("Set_Picker. 9th END point")
Else
Call REPORT_FAILURE2("Set_Picker: could not find an item, '" & pStrItemName & "'", _
"could not find and click on '" & pStrItemName & "' link on '" & pStrPickerImageAltText & "'")
Call Click_Link("Cancel", 0)
Set_Picker = FAIL
Call FUNCTION_END("Set_Picker. 10th END point")
End If

Call FUNCTION_END("Set_Picker. Last END point")

End Function 'The End Of Set_Picker Function

Function Set_Picker_DM(pStrPickerImageName, pStrPickerComboboxName, pIntIndex, pStrItemName, pStrLinkName) ' might need to change name if used outside of DM
Call FUNCTION_START("Set_Picker_DM")
Call Click_Image(pStrPickerImageName, pIntIndex)
If Link_Exists("List View", 0) Then
Call Click_Link ("List View", 0)
Else
If Not Link_Exists("Tree View", 0) Then ' page without Tree/List Views, of 'flat' page
If Link_Exists(pStrLinkName, 0) Then
Call Click_Link(pStrLinkName, 0)
Set_Picker_DM = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker_DM: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")
call FUNCTION_END("Set_Picker_DM. 1st exit point")
exit function
Else
Call Set_TextField_ByIndex (0, pStrItemName)
Call Click_Link("Find",0)
If Link_Exists(pStrLinkName, 0) Then
Call Click_Link(pStrLinkName, 0)
Set_Picker_DM = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker_DM: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")
call FUNCTION_END("Set_Picker_DM. 2nd exit point")
exit function
Else
Call Click_Link("Cancel", 0)
Set_Picker_DM = FAIL
'msgBox "Something is wrong"
Reporter.Filter = rfEnableAll

Call REPORT_FAILURE2("Set_Picker_DM: could not find an item", _
"could not find and click on '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")

call FUNCTION_END("Set_Picker_DM. 3rd exit point")
exit function
End If
End If
Else ' actual code goes here :)
Call Set_TextField_ByIndex (0, pStrItemName)
Call Click_Link("Find",0)
If Link_Exists(pStrLinkName, 0) Then
Call Click_Link(pStrLinkName, 0)
Set_Picker_DM = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker_DM: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")
call FUNCTION_END("Set_Picker_DM. 4th exit point")
exit function
Else
Call Click_Link("Cancel", 0)
Set_Picker_DM = FAIL
'msgBox "Something is wrong"

Call REPORT_FAILURE2("Set_Picker_DM: could not find an item", _
"could not find and click on '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")

call FUNCTION_END("Set_Picker_DM. 5th exit point")
exit function
End If
End If
End IF
' 01/18/05, Max: if we need to click on List View, code was doing nothing. Same change as in Set_Picker function
Call Set_TextField_ByIndex (0, pStrItemName)
Call Click_Link("Find",0)
If Link_Exists(pStrLinkName, 0) Then
Call Click_Link(pStrLinkName, 0)
Set_Picker_DM = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker_DM: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")
call FUNCTION_END("Set_Picker_DM. 6th exit point")
exit function
Else
Call Click_Link("Cancel", 0)
Set_Picker_DM = FAIL

Call REPORT_FAILURE2("Set_Picker_DM: could not find an item", _
"could not find and click on '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")

call FUNCTION_END("Set_Picker_DM. 7th exit point")
exit function
End If
Call FUNCTION_END("Set_Picker_DM. Last exit point")
End Function 'The End Of Set_Picker Function

' this function now handles any case when pop up window is open as a result of using Picker in this funciton
Function Set_Picker_Popup(pStrPickerImageName, pStrPickerComboboxName, pIntIndex, pStrItemName)
Call FUNCTION_START("Set_Picker_Popup")
' check that there is the item name on the actual combobox list
' If so, no need to click on Picker image
Dim current_window_index, new_popup_window_index
If ComboBoxItem_Exists_ByName(pStrPickerComboboxName, 0, pStrItemName) Then
Call Set_ComboBoxItem_ByName (pStrPickerComboboxName, 0, pStrItemName)
Set_Picker_Popup = PASS
Call FUNCTION_END("Set_Picker_Popup")
Exit Function
End If
' since clicking on Picker image will open pop up, need to decide how many windows are already open
' so that we properly handle windows
If wHandle2 = 0 Then
current_window_index = 1
else
current_window_index = 2 ' this means that function is being called from second pop up.
End If
new_popup_window_index = current_window_index + 1
'msgBox "new_popup_window_index = " & new_popup_window_index & " and current_window_index =" & current_window_index
Call Click_Image(pStrPickerImageName, pIntIndex)
Call Set_Window(new_popup_window_index)
If Link_Exists("List View", 0) Then
Call Click_Link ("List View", 0)
End If
If Not Link_Exists("Tree View", 0) Then ' page without Tree/List Views, of 'flat' page
If Link_Exists(pStrItemName, 0) Then
Call Click_Link(pStrItemName, 0)
Set_Picker_Popup = PASS
'msgBox "Link is shown in the UI"
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker_Popup: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")
Else
If TextField_Exists_ByIndex (0) Then
Call Set_TextField_ByIndex (0, pStrItemName)
Call Click_Link("Find",0)
end if
If Link_Exists(pStrItemName, 0) Then
Call Click_Link(pStrItemName, 0)
Set_Picker_Popup = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker_Popup: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")
Else
Call Click_Link("Cancel", 0)
Set_Picker_Popup = FAIL
'msgBox "Something is wrong"

Call REPORT_FAILURE2("Set_Picker_Popup: could not find an item", _
"could not find and click on '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")
End If
End If
Else ' actual code goes here :)
If TextField_Exists_ByIndex (0) Then
Call Set_TextField_ByIndex (0, pStrItemName)
Call Click_Link("Find",0)
end if
If Link_Exists(pStrItemName, 0) Then
Call Click_Link(pStrItemName, 0)
Set_Picker_Popup = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Picker_Popup: found an item", _
"found and set '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")
Else
Call Click_Link("Cancel", 0)
Set_Picker_Popup = FAIL
'msgBox "Something is wrong"

Call REPORT_FAILURE2("Set_Picker_Popup: could not find an item", _
"could not find and click on '" & pStrItemName & "' link on '" & pStrPickerImageName & "'")

End If
End IF
' Sync function is much better now, nothing to worry about.
'Call wait(2) 'this is for cases when after pop up closed, no page refresh is done.
Call Set_Window(current_window_index) ' Do we need to verify if value has been selected in the combo box???
Call FUNCTION_END("Set_Picker_Popup")
End Function 'The End Of Set_Picker_Popup Function

' Usage
' Call Set_Resource_Pools(Array("Jun Resource Pool11", "Jun Resource Pool12"))
' THIS SHOULD BE DPRECATED and REPLACED WITH Set_Multi_Objects_Picker
Function Set_Resource_Pools(oObjResourcePoolNames)
Call Click_Image("Select Resource Pools", 0)

Dim index
For index = 0 to Ubound(oObjResourcePoolNames)
If oObjResourcePoolNames(index) <> "" And Not IsNull(oObjResourcePoolNames(index)) Then
Call Set_TextField("obj_ListFinderDelegate_searchString", 0, oObjResourcePoolNames(index))
Call Click_Link("Find", 0)
If Click_Link(oObjResourcePoolNames(index), 0) <> PASS then

Call REPORT_FAILURE2("Set_Resource_Pools:could not find a Resource pool", _
"could not find and click on '" & oObjResourcePoolNames(index) & "' link on Resource Pool Finder page")

Set_Resource_Pools = FAIL
Call Click_Link ("Cancel", 0)
Exit Function
End If
End If
Next

Call Click_Link("OK", 0)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Resource_Pools: selected Resource pools", _
"Set_Resource_Pools: selected Resource pools")
Set_Resource_Pools = PASS

End Function 'The End Of Set_Resource_Pools Function

'This function is to select multiple objects such as:
' Resource Pools in a Project,
' Jobs and Resource pools in Skills Search, etc.
'USAGE:
' From Skills Search page
' Call Set_Multi_Objects_Picker("Select Jobs for Search", 0, Array("QA Manager"), true)
'
' These two lines
' Call Set_Multi_Objects_Picker("Select Recipients", 0, Array("chung, buu"), true)
' Call Set_Multi_Objects_Picker("Select Recipients", 0, Array("Bernard, Mark"), false)
' are equivalent to
' Call Set_Multi_Objects_Picker("Select Recipients", 0, Array("chung, buu", "Bernard, Mark"), true)
'
' If you just want to clear out all objects:
' Call Set_Multi_Objects_Picker("Select Resource Pools to Search", 0, null, true)
'
' Resource->Request Position->To
' Call Set_Multi_Objects_Picker("Select Recipients", 0, Array("Bernard, Michael", "alex, alex"), False)
Function Set_Multi_Objects_Picker(pStrPickerAltText, pIntPickerIndex, pAryStrObjectNames, pBlnClearExisting)
Call Click_Image(pStrPickerAltText, pIntPickerIndex)

'------------------------------------------------------------------------
' Deciding which page the function userd for
'------------------------------------------------------------------------
Const PAGE_TYPE_REGULAR = 0
Const PAGE_TYPE_JOB_PICKER = "PAGE_TYPE_JOB_PICKER" ' Skills Search -> Jobs Picker
Const PAGE_TYPE_RESOURCE_POOL_PICKER = "PAGE_TYPE_RESOURCE_POOL_PICKER" ' Skills Search -> Resources Picker: Project->Resources Picker
Const PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_TO = "PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_TO" ' Project commitment Suggestioon recipients to
Const PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_CC = "PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_CC" ' Project commitment Suggestioon recipients to
Const PAGE_TYPE_WORKSPACE_MEMBERSHIP = "PAGE_TYPE_WORKSPACE_MEMBERSHIP" ' Workspace -> Membership
Const PAGE_TYPE_RESOURCE_REQUEST_POSITION_TO = "PAGE_TYPE_RESOURCE_REQUEST_POSITION_TO" 'Resource->Request Position->To
Const PAGE_TYPE_RESOURCE_REQUEST_POSITION_CC = "PAGE_TYPE_RESOURCE_REQUEST_POSITION_CC" 'Resource->Request Position->CC
Const PAGE_TYPE_STAFFING_REQUESTS_SUGGEST_POSITION = "PAGE_TYPE_STAFFING_REQUESTS_SUGGEST_POSITION" 'Staffing Requests->Suggest position for xxx

Dim PAGE_TYPE_

If ComboBox_Exists("ixn_pickMultiUser_filterEntry", 0) and ComboBoxItem_Exists_ByName("ixn_pickMultiUser_filterEntry", 0, "All Project Pool Owners") Then 'this is for Resource->Request Position->To
End If

If TextField_Exists("obj_DisplayListFinderDelegate_searchString", 0) Then ' this is for job picker,etc...
PAGE_TYPE_ = PAGE_TYPE_JOB_PICKER
ElseIf TextField_Exists("obj_ListFinderDelegate_searchString", 0) Then ' this is for resource pool picker etc.
PAGE_TYPE_ = PAGE_TYPE_RESOURCE_POOL_PICKER
ElseIf Link_Exists("Resources", 0) And ComboBoxItem_Exists_ByName("ixn_pickMultiUser_filterEntry", 0, "All Project Pool Owners") And Text_Exists("Select To Recipients", 0) Then
PAGE_TYPE_ = PAGE_TYPE_RESOURCE_REQUEST_POSITION_TO
ElseIf Link_Exists("Staffing Requests", 0) And ComboBoxItem_Exists_ByName("ixn_pickMultiUser_filterEntry", 0, "All Project Pool Owners") And Text_Exists("Select To Recipients", 0) Then
PAGE_TYPE_ = PAGE_TYPE_STAFFING_REQUESTS_SUGGEST_POSITION
ElseIf Link_Exists("Resources", 0) And ComboBoxItem_Exists_ByName("ixn_pickMultiUser_filterEntry", 0, "Active Users") And Text_Exists("Select CC Recipients", 0) Then
PAGE_TYPE_ = PAGE_TYPE_RESOURCE_REQUEST_POSITION_CC
ElseIf TextField_Exists("obj_RecipientListFinderDelegate_searchString", 0) Then ' this is for Project commitment Suggestion Recipients
If ComboBoxItem_Exists_ByName("ixn_pickMultiUser_filterEntry", 0, "Active Users") Then ' This is "Select CC Recipients"
PAGE_TYPE_ = PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_CC
Else ' This is Select Recipients
PAGE_TYPE_ = PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_TO
End If
ElseIf Link_Exists("Workspaces", 0) Then ' this is for Membership in Workspace(Collaboration)
PAGE_TYPE_ = PAGE_TYPE_WORKSPACE_MEMBERSHIP
Else
PAGE_TYPE_ = PAGE_TYPE_REGULAR
End If

Call REPORT_MSG("PAGE_TYPE_ '" & PAGE_TYPE_ & "' is selected")

'Remove all from the right pane first if pBlnClearExisting = True
If pBlnClearExisting Then
Call Click_Link("Find", 0)

'Remove selected if exist
If CheckBox_Exists_ByIndex("UI:SELECT:TargetSelections:0", 0) Then
Call Set_CheckBoxOnOff_ByIndex ("UI:SELECT:TargetSelections:-1", 0, WEB_OBJECT_ON)
Call Click_Link("Remove Selected", 0)
End If
End If

'if pAryStrObjectNames = null then exiting this function
If IsNull(pAryStrObjectNames) Then
Call Click_Link("OK", 0)
Call REPORT_PASS("Set_Multi_Objects_Picker: selected objects", "Set_Multi_Objects_Picker: selected objects")
Set_Multi_Objects_Picker = PASS
Exit Function
End If

'------------------------------------------------------------------------
' Setting criteria (except for the text field. the text field should be set while loop.
'------------------------------------------------------------------------
If PAGE_TYPE_ = PAGE_TYPE_REGULAR Then
ElseIf PAGE_TYPE_ = PAGE_TYPE_JOB_PICKER Then
ElseIf PAGE_TYPE_ = PAGE_TYPE_RESOURCE_POOL_PICKER Then
Call Set_ComboBoxItem_ByName ("ixn_pickPools_mruPool", 0, "Enterprise")
ElseIf PAGE_TYPE_ = PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_TO Then
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_filterEntry", 0, "All Resource Pool Owners")
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_mruPool", 0, "Enterprise")
ElseIf PAGE_TYPE_ = PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_CC Then
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_filterEntry", 0, "Active Users")
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_mruPool", 0, "Enterprise")
ElseIf PAGE_TYPE_ = PAGE_TYPE_WORKSPACE_MEMBERSHIP Then
Call Set_ComboBoxItem_ByName ("obj_WorkspaceMembersDisplayList_currentContext", 0, "All Members")
ElseIF PAGE_TYPE_ = PAGE_TYPE_RESOURCE_REQUEST_POSITION_TO Then
' Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_filterEntry", 0, "All Project Pool Owners")
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_mruPool", 0, "Enterprise")
ElseIF PAGE_TYPE_ = PAGE_TYPE_STAFFING_REQUESTS_SUGGEST_POSITION Then
' Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_filterEntry", 0, "All Project Pool Owners")
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_mruPool", 0, "Enterprise")
ElseIF PAGE_TYPE_ = PAGE_TYPE_RESOURCE_REQUEST_POSITION_CC Then
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_filterEntry", 0, "Active Users")
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_mruPool", 0, "Enterprise")
End If

'------------------------------------------------------------------------
' Find and select objects
'------------------------------------------------------------------------
Dim index
Dim blnObjectFoundInTheIteration_
For index = 0 to Ubound(pAryStrObjectNames)
If pAryStrObjectNames(index) <> "" And Not IsNull(pAryStrObjectNames(index)) Then
blnObjectFoundInTheIteration_ = false

If PAGE_TYPE_ = PAGE_TYPE_JOB_PICKER Then
Call Set_TextField("obj_DisplayListFinderDelegate_searchString", 0, pAryStrObjectNames(index))
Call Click_Link("Find", 0)
If Click_Link(pAryStrObjectNames(index), 0) = PASS then blnObjectFoundInTheIteration_ = True

ElseIf PAGE_TYPE_ = PAGE_TYPE_RESOURCE_POOL_PICKER Then
Call Set_TextField("obj_ListFinderDelegate_searchString", 0, pAryStrObjectNames(index))
Call Click_Link("Find", 0)
If Click_Link(pAryStrObjectNames(index), 0) = PASS then blnObjectFoundInTheIteration_ = True

ElseIf PAGE_TYPE_ = PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_CC or PAGE_TYPE_ = PAGE_TYPE_PROJECT_COMMITMENT_SUGGESTION_RECIPiENTS_To Then
Call Set_TextField("obj_RecipientListFinderDelegate_searchString", 0, pAryStrObjectNames(index))
Call Click_Link("Find", 0)
If Click_Link(pAryStrObjectNames(index), 0) = PASS then blnObjectFoundInTheIteration_ = True

ElseIf PAGE_TYPE_ = PAGE_TYPE_WORKSPACE_MEMBERSHIP Then
If Click_Link(pAryStrObjectNames(index), 0) = PASS then blnObjectFoundInTheIteration_ = True

ElseIF PAGE_TYPE_ = PAGE_TYPE_RESOURCE_REQUEST_POSITION_TO Or PAGE_TYPE_ = PAGE_TYPE_STAFFING_REQUESTS_SUGGEST_POSITION Then ' This is a tricky part: There are 2 types ,"All Project Pool Owners" and "All Project Owners" and none of these covers the other.
Call Set_TextField("obj_RecipientListFinderDelegate_searchString", 0, pAryStrObjectNames(index))
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_filterEntry", 0, "All Project Pool Owners")
Call Click_Link("Find", 0)
If Link_Exists(pAryStrObjectNames(index), 0) Then
Call Click_Link(pAryStrObjectNames(index), 0)
blnObjectFoundInTheIteration_ = True
Else
Call Set_ComboBoxItem_ByName ("ixn_pickMultiUser_filterEntry", 0, "All Project Owners")
Call Click_Link("Find", 0)
If Click_Link(pAryStrObjectNames(index), 0) = PASS then blnObjectFoundInTheIteration_ = True
End If

ElseIF PAGE_TYPE_ = PAGE_TYPE_RESOURCE_REQUEST_POSITION_CC Then
Call Set_TextField("obj_RecipientListFinderDelegate_searchString", 0, pAryStrObjectNames(index))
Call Click_Link("Find", 0)
If Click_Link(pAryStrObjectNames(index), 0) = PASS then blnObjectFoundInTheIteration_ = True

End If

If Not blnObjectFoundInTheIteration_ then
Call REPORT_FAILURE2("Set_Multi_Objects_Picker:could not find a Resource pool", _
"could not find and click on '" & pAryStrObjectNames(index) & "' link on Resource Pool Finder page")
Set_Multi_Objects_Picker = FAIL
Call Click_Link ("Cancel", 0)
Exit Function
End If
End If
Next

Call Click_Link("OK", 0)
Call REPORT_PASS("Set_Multi_Objects_Picker: selected objects", "Set_Multi_Objects_Picker: selected objects")
Set_Multi_Objects_Picker = PASS

End Function 'Set_Multi_Objects_Picker

' USAGE
' Call Set_Preferences(Array("Resource", "Overall", "Job", "Job Title", "Qualifications", "Gantt View", "Skills", "Education", "Certifications", "Optional Skills", "Optional Education", "Optional Certifications", "Pool", "Workweek"))
Function Set_Preferences(pAryStrColumnNames)
Call Click_Link("Preferences", 0)
Call Set_Window(2)

Call Select_All_ListItems("selectedItems", 0)
Call Click_Link("Remove", 0)

Dim strColumnName_
For Each strColumnName_ in pAryStrColumnNames
Call Set_ListItem_ByName("unselectedItems", 0, strColumnName_, WEB_OBJECT_ON)
Call Click_Link("Add", 0)
Next
Call Click_Link("OK", 0)
Call Set_Window(1)

End Function










'Set_Classification
'
'If a test case is required to put a particular value into a particular classification, this function should be used.
'The test case should care only 3 attributes, Classification Type, Classification Name and Classification Value wraped by Classification object
'For example of 3 attribute (URL type, "Marketing campaign", http://yahoo.com) or ( User_Defined, Clients, internal)
'This function automatically put the value into a classification, either TextField or Picker, that has the same name as Classification Name parameter.
'This function set a classificaiton onto either a picker or text
'
'USAGE:1
' Dim objClassifications
' Set objClassifications = New Classification
' objClassifications.setClassificationType(CLASSIFICATION_TYPE_USER_DEFINED) ' You have to use constant valiables for setting Classfication type
' objClassifications.strClassificationName = "Clients"
' objClassifications.strClassificationValue = "Internal"
' Call Set_Classification(objClassifications)
'Usage2
' Dim objClassification1, objClassification2
' Set objClassification1 = newClassification()
' objClassification1.setClassificationType(CLASSIFICATION_TYPE_URL)
' objClassification1.strClassificationName = Chr(34) & "Marketing campaign" & Chr(34)
' objClassification1.strClassificationValue = "http://marketing.campaign.com"
'
' Set objClassification2 = newClassification()
' objClassification2.setClassificationType(CLASSIFICATION_TYPE_USER_DEFINED )
' objClassification2.strClassificationName = "Clients"
' objClassification2.strClassificationValue = "Internal"
'
' Call Click_Link("New Resource", 0)
' Call Set_Classification(objClassification1)
' Call Set_Classification(objClassification2)
' Set objClassification1 = Nothing
' Set objClassification2 = Nothing
'
'PARAMETER
' pObjClassification as Classification
'
'RETURN:
' PASS: Succeeded to set the specified classification.
' FAIL: Failed to set the specified classification because the classification could not be found.
Function Set_Classification(pObjClassification)
If pObjClassification.getClassificationType() = CLASSIFICATION_TYPE_USER_DEFINED Then
'the classification is User-Defined
If Set_Picker("Select " & pObjClassification.strClassificationName, "", 0, pObjClassification.strClassificationValue) = PASS Then
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass,_
"Set_Classification: set", _
"set '" & pObjClassification.strClassificationValue & "' in '" & pObjClassification.strClassificationName & "' field")
Set_Classification = PASS
Else

Call REPORT_FAILURE2("Set_Classification: could not set", _
"could not set '" & pObjClassification.strClassificationValue & "' in '" & pObjClassification.strClassificationName & "' field")

Set_Classification = FAIL
End If
Else
'the classification is NOT User-Defined
'Need to convert name to the other.
Dim strClassificationName_
strClassificationName_ = Replace(pObjClassification.strClassificationName, CHR(34), "_") ' character (")
strClassificationName_ = Replace(strClassificationName_, " ", "_") ' blank
strClassificationName_ = Replace(strClassificationName_, "/", "_") ' slash
Call Set_TextField ("textClassification_" & strClassificationName_ , 0, pObjClassification.strClassificationValue)
Set_Classification = PASS
End If
End Function 'The End Of Set_Classification Function





'USAGE:
' Call Set_Classification_Default_Values("Resource")
'This function goes through a ini file below called "ClassificationDefaultValues_.ini"
'to have a set of combination between classification names and values.
' ex) ClassificationDefaultValues_QA.ini
'A test case only have to call the function with object type such as "Resource". Then, values are automatically into each classifications.
'PARAMETER
' pStrObjectType as only following Strings
' "Opportunity"
' "Project"
' "Resource"
' "Client"
' "Agency"
'RETURN:
' PASS: Succeeded to set the defalut classifications to the specified object such as Resource.
' FAIL: Failed to set the defalut classification because:
' some of classification could not be found or
' ClassificationDefaultValues_.ini could not be found or
' keys or values in the ini file could not be found.
Function Set_Classification_Default_Values(pStrObjectType)
'FIX_ME **************************************************************************
'Shoud be Global constant variable
Dim CONFIG_DIR_PATH
Dim PATH_SEPARATOR
Dim LOCALE_NAME
CONFIG_DIR_PATH = "D:\dev\qa_main\prototype"
PATH_SEPARATOR = "\"
'FIX_ME **************************************************************************

Dim value_, return_, fileName_
fileName_ = CONFIG_DIR_PATH & PATH_SEPARATOR & "ClassificationDefaultValues_" & COMPANY_NAME & ".ini"

Const CAN_NOT_GET_ANY_VALUES = "can not get any value"

Dim i_
Dim objClassifications
Set objClassifications = New Classification

i_ = 0
Do While True
i_ = i_ + 1
return_ = Extern.GetPrivateProfileString(pStrObjectType, "TYPE" & i_ , CAN_NOT_GET_ANY_VALUES, value_, 32, fileName_)

If value_ = CAN_NOT_GET_ANY_VALUES Then
Exit Do
End If

If value_ = "ALPHANUMERIC" Then
objClassifications.setClassificationType(CLASSIFICATION_TYPE_ALPHANUMERIC)
ElseIf value_ = "NUMBER" Then
objClassifications.setClassificationType(CLASSIFICATION_TYPE_NUMBER)
ElseIf value_ = "URL" Then
objClassifications.setClassificationType(CLASSIFICATION_TYPE_URL)
ElseIf value_ = "USER_DEFINED" Then
objClassifications.setClassificationType(CLASSIFICATION_TYPE_USER_DEFINED)
Else
Call REPORT_FAILURE2("Set_Classification_Default_Values: found unexpected classification type", _
"found unexpected classification type '" & value_ & "'")

Set_Classification_Default_Values = FAIL
Set objClassifications = Nothing
Exit Function
End If

return_ = Extern.GetPrivateProfileString(pStrObjectType, "NAME" & i_ , CAN_NOT_GET_ANY_VALUES, value_, 32, fileName_)

If value_ = CAN_NOT_GET_ANY_VALUES Then


Call REPORT_FAILURE2("Set_Classification_Default_Values: could not find classification name", _
"could not find classification name on '" & "NAME" & i_ & "' key")

Set_Classification_Default_Values = FAIL
Set objClassifications = Nothing
Exit Function
End If

objClassifications.strClassificationName = value_

return_ = Extern.GetPrivateProfileString(pStrObjectType, "VALUE" & i_ , CAN_NOT_GET_ANY_VALUES, value_, 32, fileName_)

If value_ = CAN_NOT_GET_ANY_VALUES Then
Call REPORT_FAILURE2("Set_Classification_Default_Values: could not find classification value", _
"could not find classification value on '" & "VALUE" & i_ & "' key")

Set_Classification_Default_Values = FAIL
Set objClassifications = Nothing
Exit Function
End If
objClassifications.strClassificationValue = value_
'FIX_ME *****************************
If Set_Classification(objClassifications) = FAIL Then
End if
'FIX_ME *****************************
Loop
Set objClassifications = Nothing
End Function 'The End Of Set_Classification_Default_Values Function

'==============Set_Classification_Position ==============================
'Whenever you edit a position created from template or new position, you will
'have to set classification. This function will handle the set classification for position.
'Call this function when you are in the edit position or new position.
Function Set_Classification_Position ()
Dim objClassification1
Set objClassification1 = newClassification()
objClassification1.setClassificationType(CLASSIFICATION_TYPE_URL)
objClassification1.strClassificationName = Chr(34) & "Marketing campaign" & Chr(34)
objClassification1.strClassificationValue = "http://marketing.campaign.com"

'This check to ensure that we are in a specific edit position, where Staffing Link and Classifications Link are on that page.
If Link_Exists("Classifications", 0) or Link_Exists("Staffing", 0) or Link_Exists("Project Team Template.*", 0) Then
If Link_Exists("Classifications", 0) Then
Call Click_Link("Classifications", 0)
End If
Call Set_Classification(objClassification1)
Set objClassification1 = nothing
Set_Classification_Position = PASS
Else
Call REPORT_FAILURE("Set_Classification_Position: Unable to set Classification. Check to see if you are in a position.")

' Call REPORT_MSG("Unable to set Classification. Check to see if you are in a position.")
Set_Classification_Position = FAIL
End If

End Function 'The End of Set_Classification_Position


'FormatDateToString function should :
' have 2 arguments (pStrDateFomat, pDtmDateTime)
' return String value
' Parameters
' yyyy 4-digit year (e.g., 1998)
' yy Last 2 digits of the year (e.g., 98)
' mm Numeric month (e.g., 07)
' dd Day of month (e.g., 24)
' hh Hour of day (1-12)
' hh24 Hour of day (0-23)
' mi Minute (00-59)
' ss Second (00-59)
' Examples
' FormatDateToString(#2/7/2005#, "mm/dd/yyyy") returns "02/07/2005"
' FormatDateToString(#2/7/2005#, "m/d/yyyy") returns "2/7/2005"
' FormatDateToString(#2005/1/13#, "yyyymmdd") returns "20050113"
' FormatDateToString(#2005/1/13#, "m-d-yy") returns "1-13-05"
' FormatDateToString(cDate("October 19, 1962"), "m-d-yy") returns "10-19-62"
' FormatDateToString(now, "yyyymmddhh24miss") returns "20050330121404"
' Formatdatetostring(#2003/04/05 14:13:15#, "yyyymmddhh24miss") returns "20030405141315"
' Formatdatetostring(#2003/04/05 14:13:15#, "yyyymmddhhmiss") returns "20030405021315"
Function FormatDateToString(pDtmDateTime, pStrDateFomat)
'Verify pDtmDateTime argument is Date data type
If Not isDate(pDtmDateTime) Then
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micFail, _
"FormatDateToString: parameter is not date type", _
"second parameter('" & cstr(pDtmDateTime) & "') is not date type")
Exit Function
End If

'Start replacing
Dim strDate
strDate = pStrDateFomat

If InStr(strDate, "yyyy") <> 0 Then
strDate = Replace(strDate, "yyyy", cStr(Year(pDtmDateTime)), 1, -1, vbTextCompare)
End If

Dim strBuff
If InStr(strDate, "hh24") <> 0 Then
If Hour(pDtmDateTime) >= 10 Then
strBuff = cStr(Hour(pDtmDateTime))
Else
strBuff = "0" & Right(cStr(Hour(pDtmDateTime)), 1)
End If
strDate = Replace(strDate, "hh24", strBuff, 1, -1, vbTextCompare)
End If

If InStr(strDate, "hh") <> 0 Then
If Hour(pDtmDateTime) >= 12 Then
strBuff = Hour(pDtmDateTime) - 12
Else
strBuff = Hour(pDtmDateTime)
End If

If strBuff >= 10 Then
strBuff = cStr(strBuff)
Else
strBuff = "0" & Right(cStr(strBuff), 1)
End If

strDate = Replace(strDate, "hh", strBuff, 1, -1, vbTextCompare)
End If

If InStr(strDate, "yy") <> 0 Then
strDate = Replace(strDate, "yy", Right(cStr(Year(pDtmDateTime)), 2), 1, -1, vbTextCompare)
End If

If InStr(strDate, "mm") <> 0 Then
If Month(pDtmDateTime) >= 10 Then
strBuff = cStr(Month(pDtmDateTime))
Else
strBuff = "0" & Right(cStr(Month(pDtmDateTime)), 1)
End If
strDate = Replace(strDate, "mm", strBuff, 1, -1, vbTextCompare)
End If

If InStr(strDate, "mi") <> 0 Then
If Minute(pDtmDateTime) >= 10 Then
strBuff = cStr(Minute(pDtmDateTime))
Else
strBuff = "0" & Right(cStr(Minute(pDtmDateTime)), 1)
End If
strDate = Replace(strDate, "mi", strBuff, 1, -1, vbTextCompare)
End If

If InStr(strDate, "dd") <> 0 Then
If Day(pDtmDateTime) >= 10 Then
strBuff = cStr(Day(pDtmDateTime))
Else
strBuff = "0" & Right(cStr(Day(pDtmDateTime)), 1)
End If
strDate = Replace(strDate, "dd", strBuff, 1, -1, vbTextCompare)
End If

If InStr(strDate, "ss") <> 0 Then
If Second(pDtmDateTime) >= 10 Then
strBuff = cStr(Second(pDtmDateTime))
Else
strBuff = "0" & Right(cStr(Second(pDtmDateTime)), 1)
End If
strDate = Replace(strDate, "ss", strBuff, 1, -1, vbTextCompare)
End If

If InStr(strDate, "d") <> 0 Then
strDate = Replace(strDate, "d", cStr(Day(pDtmDateTime)), 1, -1, vbTextCompare)
End If

If InStr(strDate, "m") <> 0 Then
strDate = Replace(strDate, "m", cStr(Month(pDtmDateTime)), 1, -1, vbTextCompare)
End If

FormatDateToString = strDate

End Function

'USAGE
' msgbox RegularExpressionFormat( "Project*General .Information (Stakeholder)" )
Function RegularExpressionFormat(pStrValue)
Dim strValue_
strValue_ = replace(pStrValue, "(", "\(")
strValue_ = replace(strValue_ , ")", "\)")
strValue_ = replace(strValue_ , ".", "\.")
strValue_ = replace(strValue_ , "*", "\*")
RegularExpressionFormat = strValue_
End Function

' CaptureWindowImage
'
' Description
' This function create a folder for saving images of window ( for one time)
' This function captures a current window image as a png file when called.
' The image is stored in CAPTURED_WINDOW_IMAGE_PATH folder with timestamp
' May be this function needs to be added to a part of functions which has micFail of Reporter object such as :
' When Click_Link can not click the specified link
' When Verify_WebTable_Cell command identifys the specified cell does not exist.
' HISTORY
' 06/16/2006 Jun Changed the file name format that time stamp comes first and page name follows, because you can use Windows Picture and Fax View by keying right and left and can pursuit images in a order by occurence.
'
' Usage
' Call CaptureWindowImage("This is a message")
Function CaptureWindowImage(pStrMessage)

If Not CAPTURE_WINDOW_IMAGE_ENABLE Then
Call REPORT_MSG2("CaptureWindowImage function skipped", "CaptureWindowImage function skipped. If you want to enable this function, make CAPTURE_WINDOW_IMAGE_ENABLE = True in properties.vbs")
Exit Function
End If

Reporter.Filter = rfDisableAll
If Not Browser("hwnd:=" & hWindow).Exist Then
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"CaptureWindowImage could not capture a window image", _
"CaptureWindowImage could not capture a window image because a window handle '" & hWindow & "' was not valid")
Exit Function
End If

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(CAPTURED_WINDOW_IMAGE_PATH) Then
fso.CreateFolder(CAPTURED_WINDOW_IMAGE_PATH)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"CaptureWindowImage created a folder", _
"CaptureWindowImage created a folder as '" & CAPTURED_WINDOW_IMAGE_PATH & "'")
Reporter.Filter = rfDisableAll
End If

'Look for files which are older than 1 week old and delete them.
Dim objFolder
Set objFolder = fso.GetFolder(CAPTURED_WINDOW_IMAGE_PATH)
Dim objFiles
Set objFiles = objFolder.Files
Dim objFile
Dim blnNeedToDelete
blnNeedToDelete = false
For Each objFile in objFiles
If DateDiff("d", objFile.DateCreated, Date) > 7 Then
blnNeedToDelete = True
objFile.Delete
End If
Next

If blnNeedToDelete Then
Call REPORT_MSG2("CaptureWindowImage deleted all old files", "CaptureWindowImage deleted all old files in '" & CAPTURED_WINDOW_IMAGE_PATH & "'")
End If

Set fso = Nothing
Set objFolder = Nothing
Set objFiles = Nothing
Set objFile = Nothing

Dim pageTitle, fileName, fileFullPath
pageTitle = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).GetROProperty("Title")
pageTitle = Replace(pageTitle, "/", "_")
pageTitle = Replace(pageTitle, "\", "_")
pageTitle = Replace(pageTitle, ":", "_")
pageTitle = Replace(pageTitle, "*", "_")
pageTitle = Replace(pageTitle, "?", "_")
pageTitle = Replace(pageTitle, "<", "_")
pageTitle = Replace(pageTitle, ">", "_")
pageTitle = Replace(pageTitle, "|", "_")
pageTitle = Replace(pageTitle, Chr(34), "_")
pageTitle = Replace(pageTitle, " ", "_")
fileName = FormatDateToString(Now(), "yymmddhh24miss") & "_" & pageTitle & ".png"
fileFullPath = CAPTURED_WINDOW_IMAGE_PATH & "\" & fileName

Call Browser("hwnd:=" & hWindow).CaptureBitmap(fileFullPath, true)

Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
pageTitle & " captured", _
"CaptureWindowImage captured " & pageTitle & " page at " & vbCRLF & _
fileFullPath & "in " & HOST_MACHINE_NAME & vbCRLF & _
"Message is '" & pStrMessage & "' " & vbCRLF & _
"\\" & HOST_MACHINE_NAME & "\CapturedWindowImage\" & fileName)

End Function ' End Of CaptureWindowImage Function



'
'RETURN
' array of String
'
' USAGE
' SeparateToken("All Template Types;Work Request;Change Request" , ";") -> Array("All Template Types", "Work Request", "Change Request")
Function SeparateToken(pStrLine, pStrToken)
Dim strings_()
Dim numberOfToken
Dim seekPosition_

numberOfToken = 0
seekPosition_ = 1
Do
Dim nextPositionFound_
ReDim Preserve strings_(numberOfToken )
nextPositionFound_ = Instr(seekPosition_, pStrLine, pStrToken, vbTextCompare)
If nextPositionFound_ = 0 Then
strings_(numberOfToken ) = mid(pStrLine, seekPosition_, len(pStrLine) )
Exit Do
End if
strings_(numberOfToken ) = mid(pStrLine, seekPosition_, nextPositionFound_- seekPosition_)
seekPosition_ = nextPositionFound_ + 1
numberOfToken = numberOfToken + 1
Loop
SeparateToken = strings_
End Function



'External functions
'RETURN
' the number of characters.
'PARAMETERS
' Application name
' Key name
' Defalut value
' Returned value
' Size
' File name
Extern.Declare micInteger,"GetPrivateProfileString", "kernel32.dll","GetPrivateProfileStringA", _
micString, _
micString, _
micString, _
micString+micByRef, _
micInteger, _
micString

'This function counts number of processes, not windows.
'For instance, Launching IE and java scripts in the IE page pop up another page, count of process would still be 1.
Function Count_Processes(sStrProcessName)
Dim objSWbemServices, colSWbemObjectSet
Set objSWbemServices = GetObject("winmgmts:")
Set colSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM Win32_Process Where Name = '"& sStrProcessName &"'")
Count_Processes = colSWbemObjectSet.Count
End Function




'This functions are used to report messages to the test results. These messages are used for improved
' readability of test results report
Function REPORT_MSG(msg)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, functionHierarchyLevel.generateBufForReporter() & msg, msg)
End Function

'This should be used since there are a lot of Reporter.filter control.
Function REPORT_MSG2(reportStepName, details)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, functionHierarchyLevel.generateBufForReporter() & reportStepName, details)
End Function

Function REPORT_PASS(reportStepName, details)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass, functionHierarchyLevel.generateBufForReporter() & reportStepName, details)
End Function


Function REPORT_FAILURE(msg)
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micFail, functionHierarchyLevel.generateBufForReporter() & msg, msg
Call CaptureWindowImage(msg)
End Function

'This should be used since there are a lot of Reporter.filter control.
Function REPORT_FAILURE2(reportStepName, details)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micFail, functionHierarchyLevel.generateBufForReporter() & reportStepName, details)
Call CaptureWindowImage(details)
End Function

Function REPORT_FAILURE_NO_IMAGE(reportStepName, details)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micFail, functionHierarchyLevel.generateBufForReporter() & reportStepName, details)
End Function

' This function write a failure on QTP reports if the bug number is still a open bug.
' Once a bug whose number is used in this functioin as an argument is closed,:
' 1. Add the bug number to a file named FixedBugList.lst
' 2. DO NOT need to change ANYTHING in your test script.
'
' //depot/qa_main/ATSDGuide/TestSuite/configure/FixedBugList.lst
'
' USAGE
' Call REPORT_FAILURE_DUE_TO_KNOWN_ISSUE("11111", "xxx is a bug", True)
' Call REPORT_FAILURE_DUE_TO_KNOWN_ISSUE("22222", "xxx is a bug", True)
' Call REPORT_FAILURE_DUE_TO_KNOWN_ISSUE("33333", "xxx is a bug", True)
' Call REPORT_FAILURE_DUE_TO_KNOWN_ISSUE("11111", "xxx is a bug", True)
Dim aryFixedBugNumbers
aryFixedBugNumbers = null
Function REPORT_FAILURE_DUE_TO_KNOWN_ISSUE(pStrBugNumber, pStrMessage, pBlnCaptureScreen)
Dim stillKnownIssue
stillKnownIssue = true

' Here is an external text file that has a list of fixed bug.
' Read the file, if the specified bug number found, then this does not report anytihing
If IsNull(aryFixedBugNumbers) Then
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim objTextStream
Set objTextStream= fso.OpenTextFile(ATSD_CONFIG_FOLDER & "\FixedBugList.lst")

Dim strTextStream
strTextStream = objTextStream.ReadAll
objTextStream.Close

aryFixedBugNumbers = split(strTextStream, vbNewLine)

Call REPORT_MSG2("Bug Numbers in FixedBugList.lst have been read into aryFixedBugNumbers", "Bug Numbers are: " & strTextStream)

Set fso = Nothing
End If

Dim fixedBugNumber
For Each fixedBugNumber in aryFixedBugNumbers
If Trim(fixedBugNumber) = pStrBugNumber Then
stillKnownIssue = False
Exit For
End If
Next

If stillKnownIssue Then
If pBlnCaptureScreen Then
Call REPORT_FAILURE2("KNOWN ISSUE:" & pStrBugNumber, "KNOWN ISSUE:" & pStrBugNumber & " " & pStrMessage)
Else
Call REPORT_FAILURE_NO_IMAGE("KNOWN ISSUE:" & pStrBugNumber, "KNOWN ISSUE:" & pStrBugNumber & " " & pStrMessage)
End If
Else
Call REPORT_MSG("This used to be a known issue(" & pStrBugNumber & ")")
End If

End Function

Function REPORT_WARNING(msg)
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micWarning, functionHierarchyLevel.generateBufForReporter() & msg, msg
End Function

Function REPORT_WARNING2(reportStepName, details)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micWarning, functionHierarchyLevel.generateBufForReporter() & reportStepName, details)
End Function

Function SCRIPT_BLOCK(msg)
REPORT_MSG("********SCRIPT_BLOCK********: " & msg)
End Function


'
Class FunctionHierarchyLevelController
Private functionHierarchyLevel_

Private Sub Class_Initialize()
functionHierarchyLevel_ = 0
End Sub

Public Function start(function_name)
functionHierarchyLevel_ = functionHierarchyLevel_ + 1
Call REPORT_MSG2(function_name & " function start", function_name & " funciton starts. calling level is " & functionHierarchyLevel_)
End Function

'end is defined and can not be used here, thus "fend"
Public Function fend(function_name)
Call REPORT_MSG2(function_name & " funciton end", function_name & " funciton ends. calling level is " & functionHierarchyLevel_)
functionHierarchyLevel_ = functionHierarchyLevel_ - 1
End Function

Public Function generateBufForReporter()
If functionHierarchyLevel_ = 0 Then
Exit Function
End If

Dim index_
Dim buffer_
buffer_ = ""
For index_ = 0 To functionHierarchyLevel_ - 1
buffer_ = buffer_ & "_"
Next

generateBufForReporter = buffer_ & functionHierarchyLevel_

End Function

Private Sub Class_Terminate()
functionHierarchyLevel_ = 0
End Sub

End Class

Public functionHierarchyLevel
Set functionHierarchyLevel = new FunctionHierarchyLevelController



Function FUNCTION_START(function_name)
REPORT_MSG(function_name)
End Function

Function FUNCTION_END(function_name)
REPORT_MSG("********FUNCTION_END********: " & function_name)
End Function

function REPORT_MESSAGE(msg)
Call REPORT_MSG(msg)
Call REPORT_WARNING("REPORT_MESSAGE function has been retired. Please update script to use REPORT_MSG function")
end function










'-----------------------------------------------------------------------------------------
' Workaround section
'-----------------------------------------------------------------------------------------


'Defect 36189 in Vantive
Function WorkaroundFor36189
If Browser("hwnd:=" & hWindow).Dialog("title:=Security Alert").WinButton("text:=&Yes").Exist(OBJECT_EXIST_TIME_OUT) Then
Browser("hwnd:=" & hWindow).Dialog("title:=Security Alert").WinButton("text:=&Yes").Click
Call REPORT_FAILURE("WorkaroundFor36189")
End If
End Function

'Defect 35453 in Vantive
Function WorkaroundFor35453
Call REPORT_FAILURE("WorkaroundFor35453: Move: inconsistent order of names.")
End Function

'Defect 36208(Version History shows wrong Modified By field.) in Vantive
Function WorkaroundFor36208
Call REPORT_FAILURE("WorkaroundFor36208: Version History shows wrong Modified By field.")
End Function


'Defect 36497(Dependency on objects does not work when Importer deletes the objects) in Vantive
Function WorkaroundFor36497
Call REPORT_FAILURE("WorkaroundFor36497: Dependency on objects does not work when Importer deletes the objects")
End Function

'Defect r35655 in Vantive
Function WorkaroundFor35655
If Browser("hwnd:=" & hWindow).Dialog("title:=Security Information").WinButton("text:=&Yes").Exist(OBJECT_EXIST_TIME_OUT) Then
Browser("hwnd:=" & hWindow).Dialog("title:=Security Information").WinButton("text:=&Yes").Click
End If
End Function

'Defect 39512 in QC
Function WorkaroundFor39512()
' workaround function:
' if dialog exists, clickYes, and fail script with message that includes bug number
If IFrameButton_Exists("Yes", 0) Then
Call Click_IFrameButton("Yes", 0)
Call REPORT_FAILURE("WorkaroundFor39512: Known issue. See bug # 39512. Everything else will fail from here onward.")
Else
Call REPORT_WARNING("Please remove this workaround when the bug is fixed.")
End If

End Function

'Workaround for the account owner in different order
Function WorkaroundFor40534
Call REPORT_MESSAGE("KNOWN PROBLEM: 40534")
Call REPORT_FAILURE("WorkaroundFor40534: Client Owners In Relationship Doesn't Appear To Any Particular Order, hence led failure in verifying table.")
End Function


' In 8.6, we have been introducing a new Flex T&E and as a transition we have 2 clicks to go to T&E instead of 1 click
Function Workaround_This_Has_To_Be_Replaced_After_Flex_implemented
Call REPORT_WARNING2("Workaround_This_Has_To_Be_Replaced_After_Flex_implemented", "Workaround_This_Has_To_Be_Replaced_After_Flex_implemented")
Call Click_Link("Time and Expenses", 0)
Call Click_Link("Time and Expenses", 0)
End Function


'========================================================================================
' This TB TL Configure Popup functions has been converted to editable fields by Venkat.... and submited by Ariff

Function Set_Values_In_TeamBuilder_Configure_Popup(val1, val2, val3, val4, val5, val6, val7, val8, val9)
Call Click_Link("Configure Search",0)
Call Set_Window(2)
Call Set_TextField("obj_SuitabilityConfiguration_jobsWeight", 0, val1)
Call Set_TextField("obj_SuitabilityConfiguration_qualificationsWeight", 0, val2)
Call Set_TextField("obj_SuitabilityConfiguration_availabilityWeight", 0, val3)
Call Set_TextField("obj_SuitabilityConfiguration_skillsWeight", 0, val4)
Call Set_TextField("obj_SuitabilityConfiguration_certificationsWeight", 0, val5)
Call Set_TextField("obj_SuitabilityConfiguration_knowledgeWeight", 0, val6)
Call Set_TextField("obj_SuitabilityConfiguration_overallThreshold", 0, val7)
Call Set_TextField("obj_SuitabilityConfiguration_availabilityThreshold", 0, val8)
Call Set_TextField("obj_SuitabilityConfiguration_qualificationsThreshold", 0, val9)
Call Click_Link("OK",0)
Call Set_Window(1)
End Function



Function Set_Values_In_TeamLocator_Configure_Popup(val1, val2, val3, val4, val5, val6, val7, val8, val9)
Call Click_Link("Configure Search",0)
Call Set_Window(2)
Call Set_TextField("obj_SuitabilityConfiguration_jobsWeight", 0, val1)
Call Set_TextField("obj_SuitabilityConfiguration_qualificationsWeight", 0, val2)
Call Set_TextField("obj_SuitabilityConfiguration_availabilityWeight", 0, val3)
Call Set_TextField("obj_SuitabilityConfiguration_skillsWeight", 0, val4)
Call Set_TextField("obj_SuitabilityConfiguration_certificationsWeight", 0, val5)
Call Set_TextField("obj_SuitabilityConfiguration_knowledgeWeight", 0, val6)
Call Set_TextField("obj_SuitabilityConfiguration_overallThreshold", 0, val7)
Call Set_TextField("obj_SuitabilityConfiguration_availabilityThreshold", 0, val8)
Call Set_TextField("obj_SuitabilityConfiguration_qualificationsThreshold", 0, val9)
Call Click_Link("OK",0)
Call Set_Window(1)
End Function
'========================================================================================
'03/10/2006, Max - date takes system date, but skips leading 0 (our app uses it)
function Get_Today()

Call REPORT_FAILURE_NO_IMAGE("Get_Today is DEPRECATED", _
"USE: 'FormatDateToString(now, ""mm/dd/yyyy"")' instead")

Dim Date_Array
Date_Array = split(date, "/")
If Len(Date_Array(0)) <2 Then
Date_Array(0) = "0" & Date_Array(0)
End If
If Len(Date_Array(1)) <2 Then
Date_Array(1) = "0" & Date_Array(1)
End If
Get_Today = Date_Array(0) & "/" & Date_Array(1) & "/" & Date_Array(2)
end function

' **************** Move Project Dates & Positions dates Updates TL specific Functions By venkat **********************************

Function GetMondayDate(RefDate)
Dim MyWeekDay, MondayDate
MyWeekDay = Weekday(RefDate,2) ' 1. Monday , 2. Tuesday, 3. Wednesday, 4. Thursday, 5. Friday, 6. Saturday, 7. Sunday
Select Case MyWeekDay
Case 1
MondayDate= RefDate
Case 2
MondayDate= DateAdd("d", -1, RefDate)
Case 3
MondayDate= DateAdd("d", -2, RefDate)
Case 4
MondayDate= DateAdd("d", -3, RefDate)
Case 5
MondayDate= DateAdd("d", -4, RefDate)
Case 6
MondayDate= DateAdd("d", -5, RefDate)
Case 7
MondayDate= DateAdd("d", -6, RefDate)
End Select
GetMondayDate = MondayDate
End Function

'Deprecated 04/27/2006 Jun
Function MoveProjectDate(ProName)
Dim MoveDate, AddDay
Call REPORT_FAILURE2("MoveProjectDate is DEPRECATED", _
"Due to a lack of explanation and too generic name: use changeProjectStartDateTo1stOfNextMonth function") 'Added by Jun

Call FUNCTION_START("Move Project Dates ....")
MoveDate = Date
MoveDate=DateAdd("m", 1 , MoveDate)
AddDay= Day(MoveDate)
MoveDate=DateAdd("d", -(AddDay-1) , MoveDate)
Call Open_Project(ProName)
Call Click_Link("Project Dates",0)
Call Set_TextField ("ixn_projectMoveDates_startDate",0,MoveDate)
Call Click_Link("Save and Close","0")
MoveProjectDate = MoveDate
Call FUNCTION_END("Move Project Dates ....")
End Function

'This function sets the 1st day of the next month
'If today is 04/27/2006, this sets 05/01/2006
Function changeProjectStartDateTo1stOfNextMonth(pStrProjectName)
Dim MoveDate, AddDay
Call FUNCTION_START("Move Project Dates ....")
MoveDate = Date
MoveDate=DateAdd("m", 1 , MoveDate)
AddDay= Day(MoveDate)
MoveDate=DateAdd("d", -(AddDay-1) , MoveDate)
Call Open_Project(pStrProjectName)
Call Click_Link("Project Dates",0)
Call Set_TextField ("ixn_projectMoveDates_startDate",0,MoveDate)
Call Click_Link("Save and Close","0")
changeProjectStartDateTo1stOfNextMonth = MoveDate
Call FUNCTION_END("Move Project Dates ....")
End Function


Function UpdatePositionDates(PosName, StartDay,PosDuration) 'StartDay, values are 'Existing Day to fwd Days -------->>> 1. for Monday , 2. Tuesday, 3. Wednesday, 4. Thursday, 5. Friday, 6. Saturday, 7. Sunday
'Existing Day to Bkwd Days ------>>> 0.for Sunday , -1 Saturday -2 Friday , -3 Thursday ,-4 Wednesday,-5 Tuesday
Dim PosMovStartDate, PosMovEndDate, AddDay
Call FUNCTION_START("Update Position Dates ....")
PosMovStartDate = Date
PosMovStartDate=DateAdd("m", 1 , PosMovStartDate)
AddDay= Day(PosMovStartDate)
PosMovStartDate=DateAdd("d", -(AddDay-1) , PosMovStartDate)
Call Click_Link(PosName, 0)
PosMovStartDate = DateAdd("d",15, PosMovStartDate)
PosMovStartDate = GetMondayDate(PosMovStartDate)
If StartDay <> 1 Then
PosMovStartDate = DateAdd("d", (StartDay-1), PosMovStartDate)
End If
PosMovEndDate = DateAdd("d", (PosDuration-1), PosMovStartDate)
Call Set_TextField("ixn_editPosition_startDate",0,PosMovStartDate )
Call Set_TextField("ixn_editPosition_endDate",0, PosMovEndDate )
Call Click_Link("Save and Close", 0)
If IFrameButton_Exists ("Yes",0) Then
Call Click_IFrameButton("Yes",0)
End if
If IFrameButton_Exists ("Yes",0) Then
Call Click_IFrameButton("Yes",0)
End if
Call FUNCTION_END("Update Position Dates ....")
End Function

Function GenerateFullName(pStrLastName, pStrFirstName)
GenerateFullName = pStrLastName & ", " & pStrFirstName
End Function


Function SetReplyTypeMouse()
Setting.WebPackage("ReplayType") = 2
End Function

Function SetReplyTypeEvent()
Setting.WebPackage("ReplayType") = 1
End Function

Function SetReplyType(pIntReplyType)
Setting.WebPackage("ReplayType") = pIntReplyType
End Function



' **************** Move Project Dates & Positions dates Updates TL specific Functions By venkat **********************************

'Option Explicit
'Call SendTabKey

Function SendTabKey()
Dim WshShell
set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{TAB}"
set WshShell = Nothing
End Function

' *******************************************************************************************

Function Del_Browser_Cookies
Dim WshShell
set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "%(to)"
set WshShell = Nothing
Browser("hwnd:=" & hWindow).Dialog("text:= Internet Options").WinButton("text:= Delete Coo.*","Index:= 0").Click
Browser("hwnd:=" & hWindow).Dialog("text:= Internet Options").Dialog("text:= Delete Cookies").WinButton("text:= OK","Index:= 0").Click
Browser("hwnd:=" & hWindow).Dialog("text:= Internet Options").WinButton("text:= Delete &Files.*","Index:= 0").Click
Browser("hwnd:=" & hWindow).Dialog("text:= Internet Options").Dialog("text:= Delete Files").WinCheckBox("text:= &Delete all offline content","Index:= 0").Set "ON"
Browser("hwnd:=" & hWindow).Dialog("text:= Internet Options").Dialog("text:= Delete Files").WinButton("text:= OK","Index:= 0").Click
Browser("hwnd:=" & hWindow).Dialog("text:= Internet Options").WinButton("text:= OK","Index:= 0").Click
End Function

'End Of File



' ==============================================================================================================
' Functions to click Edit Links and Expand Image on all Object profile screens.........Venkat
' ==============================================================================================================

'HISTORY
' 2006/04/19 Jun: Overhauled Expand_Profile.
' Description
' 1. Get_WebTable_Cell
' It is not always possible to get a value in cell (1,3) through Get_WebTable_Cell.
' If the function fails, it causes a failure.
' but there is no need to get the cell value, all you need it the image object.
' 2. unnecessary Warnings
' 3. Move the function from Business.vbs to Utility.vbs
Function Expand_Profile(pStrProfileLabel)
Dim translated_name_

translated_name_ = Local_Text(pStrProfileLabel)

' ActualValue = "Expand"
Call Initiate_wHandle

'look for "index 0"

' The actual web table's index can be 0 or 1. Mostly 0 but 1 in a few case such as Projects pane in Client
If Not WebTable_Cell_Exsists(translated_name_, 0, 1, 3) Then
Call REPORT_FAILURE2("Expand_Profile: '" & pStrProfileLabel & "' toggle cell Not Found", "Expand_Profile could not find a toggle cell in WebTable('" & pStrProfileLabel & "', 0) translated to '" & translated_name_ & "'")
Expand_Profile = FAIL
Exit Function
End If

Dim objWebImage_

'If there is not critical error, then needs to look for "index 1".
If Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & translated_name_ & ".*","Index:=0").ChildItemCount(1, 3, "Image") > 0 Then

Set objWebImage_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & translated_name_ & ".*","Index:=0").ChildItem(1, 3, "Image", 0)

If objWebImage_.Exist(OBJECT_EXIST_TIME_OUT) Then
If objWebImage_.GetROProperty("file name") = "wb-up.gif" Then
objWebImage_.Click
Sync_Page
Call REPORT_MSG2("Expand_Profile: '" & pStrProfileLabel & "' expaneded", "Expanded ' " & pStrProfileLabel & "' Profile frame successfully.")
Expand_Profile = PASS
Set objWebImage_ = Nothing
Exit Function
ElseIf objWebImage_.GetROProperty("file name") = "wb-dwn.gif" Then
Call REPORT_MSG2("Expand_Profile: the profile already expanded", "'" & pStrProfileLabel & "' Profile already expanded ...Hence avoiding clicking expand image.")
Expand_Profile = PASS
Set objWebImage_ = Nothing
Exit Function
End If
End If
End If

'look for index 1

' If "index 1" does not have cell or image, this function should fail because there is not "Index 2" supoped to have the image.
If Not WebTable_Cell_Exsists(translated_name_, 1, 1, 3) Then
Call REPORT_FAILURE2("Expand_Profile: '" & pStrProfileLabel & "' web table Not Found", "Expand_Profile could not find a toggle cell in WebTable('" & pStrProfileLabel & "', 1) translated to '" & translated_name_ & "'")
Expand_Profile = FAIL
Exit Function
End If

If Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & translated_name_ & ".*","Index:=1").ChildItemCount(1, 3, "Image") = 0 Then
Call REPORT_FAILURE2("Expand_Profile: '" & pStrProfileLabel & "' the toggle image Not Found", "Expand_Profile could not find a toggle cell in WebTable('" & pStrProfileLabel & "', 1) translated to '" & translated_name_ & "'")
Expand_Profile = FAIL
Exit Function
End If

Set objWebImage_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & translated_name_ & ".*","Index:=1").ChildItem(1, 3, "Image", 0)

'If there is not a toggle image, then it is an error
If Not objWebImage_.Exist(OBJECT_EXIST_TIME_OUT) Then
Call REPORT_FAILURE2("Expand_Profile: '" & pStrProfileLabel & "' the toggle image Not Found", "Expand_Profile could not find a toggle cell in WebTable('" & pStrProfileLabel & "', 1) translated to '" & translated_name_ & "'")
Expand_Profile = FAIL
Set objWebImage_ = Nothing
Exit Function
End If

If objWebImage_.GetROProperty("file name") = "wb-up.gif" Then
objWebImage_.Click
Sync_Page
Call REPORT_MSG2("Expand_Profile: '" & pStrProfileLabel & "' expaneded", "Expanded ' " & pStrProfileLabel & "' Profile frame successfully.")
Expand_Profile = PASS
ElseIf objWebImage_.GetROProperty("file name") = "wb-dwn.gif" Then
Call REPORT_MSG2("Expand_Profile: the profile already expanded", "'" & pStrProfileLabel & "' Profile already expanded ...Hence avoiding clicking expand image.")
Else
Call REPORT_FAILURE2("Expand_Profile: toggle image not found", "Expand Image link not Found: WebTable name = '" & pStrProfileLabel & "' Image file name captured is ='" & strImageFileName_ & "' NOT wb-up.gif or wb-dwn.gif")
Expand_Profile = FAIL
End If

Set objWebImage_ = Nothing

End Function


Function Edit_Profile(text)
Dim WebLinkObj,index , LinkName , ActualValue_1,ActualValue_0
dim translated_name_, translated_Linkname_
translated_name_ = Local_Text(text)
Reporter.Filter = rfDisableAll

Call Initiate_wHandle ' 'added by Jun 20050830
LinkName = "Edit"
If text = "Tasks" then
linkName = "ViewEdit"
end if

translated_Linkname_ = Local_Text(linkName)
If WebTable_Exists(translated_name_, 1) Then
ActualValue_1 = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:="& translated_name_ & ".*", "Index:= 1").GetCellData (1,2)
'Get_WebTable_Cell(text, 1, 1, 2)
End If
If WebTable_Exists(translated_name_, 0) Then
ActualValue_0 = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:="& translated_name_ & ".*", "Index:= 0").GetCellData (1,2)
'Get_WebTable_Cell(text, 1, 1, 2)
End If

If Trim(ActualValue_1) = Trim(translated_Linkname_) Then
index = 1
Call REPORT_WARNING("Table Index is 1.")
elseif Trim(ActualValue_0) = Trim(translated_Linkname_) Then
index = 0
Call REPORT_WARNING("Table index is 0")
else
Call REPORT_FAILURE2("Edit_Profile", _
"WebTable Not Found or Link Name is Incorrect: WebTable name = '" & translated_name_ & "' WebTable index ='" & index & "' Link Name : '" & LinkName & "'")
Edit_Profile = FAIL
Reporter.Filter = rfEnableAll
Exit Function
End if

Set WebLinkObj =Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & translated_name_ & ".*","Index:=" & index).ChildItem(1, 2, "Link", 0)

WebLinkObj.Click
Sync_Page
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Edit_Profile", _
" Edit Profile '" & text & "' is successfull "
Edit_Profile = PASS
Set WebLinkObj = Nothing

End Function


'------------------------------------------------------------------------------------------------------------
' Wait & Synchronization Functions
'------------------------------------------------------------------------------------------------------------
'This is a special sync function with a page loaded.
Function WaitWhileTextIsShown (pStrTextToLookFor, pIntTimeOutSecond)
Dim FREQUNECY_SECOND_
FREQUNECY_SECOND_ = 2

Dim counter_
counter_ = 0

Do While Text_Exists(pStrTextToLookFor,0)
Wait FREQUNECY_SECOND_
counter_ = counter_ + 1
If counter_ * FREQUNECY_SECOND_ >= pIntTimeOutSecond Then
' Time out
Call REPORT_MSG2("TIME OUT: WaitWhileTextIsShown: '" & pStrTextToLookFor & "' still there", _
"WaitWhileTextIsShown time out because '" & pStrTextToLookFor & "' still there after waited for " & counter_ * FREQUNECY_SECOND_ & " second.")
Exit Function
End If
Loop

' The text is gone.
Call REPORT_MSG2("WaitWhileTextIsShown: '" & pStrTextToLookFor & "' Not Shown", _
"WaitWhileTextIsShown: exits because '" & pStrTextToLookFor & "' is not shown after waited for " & counter_ * FREQUNECY_SECOND_ & " second.")

End Function


'This is a special sync function with a page loaded.
'USAGE
' Call WaitWhileTextIsNotShown("Password:", 20) ' This waits at most 20 second
Function WaitWhileTextIsNotShown (pStrTextToLookFor, pIntTimeOutSecond)
Dim FREQUNECY_SECOND_
FREQUNECY_SECOND_ = 2

Call REPORT_WARNING("This should be deprecated: Use WaitUntilTextIsShown instead of WaitWhileTextIsNotShown")

Dim counter_
counter_ = 0

Do Until Text_Exists(pStrTextToLookFor,0)
Wait FREQUNECY_SECOND_
counter_ = counter_ + 1
If counter_ * FREQUNECY_SECOND_ >= pIntTimeOutSecond Then
' Time out
Call REPORT_MSG2("TIME OUT: WaitWhileTextIsNotShown: '" & pStrTextToLookFor & "' still Not Shown", _
"WaitWhileTextIsNotShown: time out because '" & pStrTextToLookFor & "' is not shown after waited for " & counter_ * FREQUNECY_SECOND_ & " second.")
Exit Function
End If
Loop

' The text is shown.
Call REPORT_MSG2("WaitWhileTextIsNotShown: '" & pStrTextToLookFor & "' Shown", _
"WaitWhileTextIsNotShown exits because '" & pStrTextToLookFor & "' shown after waited for " & counter_ * FREQUNECY_SECOND_ & " second.")

End Function



'This is a special sync function with a page loaded.
'USAGE
' Call WaitUntilTextIsShown("Password:", 20) ' This waits at most 20 second
Function WaitUntilTextIsShown (pStrTextToLookFor, pIntTimeOutSecond)
Dim FREQUNECY_SECOND_
FREQUNECY_SECOND_ = 2

Dim counter_
counter_ = 0

Do Until Text_Exists(pStrTextToLookFor,0)
Wait FREQUNECY_SECOND_
counter_ = counter_ + 1
If counter_ * FREQUNECY_SECOND_ >= pIntTimeOutSecond Then
' Time out
Call REPORT_MSG2("TIME OUT: WaitUntilTextIsShown: '" & pStrTextToLookFor & "' still Not Shown", _
"WaitUntilTextIsShown: time out because '" & pStrTextToLookFor & "' is not shown after waited for " & counter_ * FREQUNECY_SECOND_ & " second.")
Exit Function
End If
Loop

' The text is shown.
Call REPORT_MSG2("WaitUntilTextIsShown: '" & pStrTextToLookFor & "' Shown", _
"WaitUntilTextIsShown exits because '" & pStrTextToLookFor & "' shown after waited for " & counter_ * FREQUNECY_SECOND_ & " second.")

End Function

' This repeats clicking a specified link until another link is shown
' Example:
' a script wants to wait by repeating "Refresh" until a message in Collaboration arrives and shown.
Function RepeatClickUntilLinkShown(pStrLinkToRepeatClicking, pIntRepeatIntervalSecond, pStrLinkWaitFor, pIntTimeOutSecond)

If pIntRepeatIntervalSecond <= 0 Then
Call REPORT_FAILURE2("RepeatClickUntilLinkShown: pIntRepeatIntervalSecond is not valid", "RepeatClickUntilLinkShown: pIntRepeatIntervalSecond is not valid")
Exit Function
End If

Dim counter_
counter_ = 0

Do Until Link_Exists(pStrLinkWaitFor,0)
Wait pIntRepeatIntervalSecond
counter_ = counter_ + 1
Call Click_Link(pStrLinkToRepeatClicking, 0)
If counter_ * pIntRepeatIntervalSecond >= pIntTimeOutSecond Then
' Time out
Call REPORT_MSG2("TIME OUT: RepeatClickUntilLinkShown: '" & pStrLinkWaitFor & "' still Not Shown", _
"RepeatClickUntilLinkShown: time out because '" & pStrLinkWaitFor & "' is not shown after waited for " & counter_ * FREQUNECY_SECOND_ & " second.")
Exit Function
End If
Loop

' The text is shown.
Call REPORT_MSG2("RepeatClickUntilLinkShown: '" & pStrLinkWaitFor & "' Shown", _
"RepeatClickUntilLinkShown exits because '" & pStrLinkWaitFor & "' shown after waited for " & counter_ * FREQUNECY_SECOND_ & " second.")
End Function ' End of RepeatClickUntilLinkShown







'Mercury Support function
' http://kb-index.mercury.com/web/queries/KBAview.asp?Conceptid=32103&Product=AQT
'
function readIniFile(pStrIniFile, pStrSection, pStrKey)
Const ForReading = 1
Dim fso, f, ts, currSec, currVar, continueLooking, objDictionary
continueLooking = true
currSec = false
currVar = false
Set fso = CreateObject("Scripting.FileSystemObject")

set objDictionary = CreateObject("Scripting.Dictionary")
Set ts = fso.OpenTextFile(pStrIniFile)

Dim strTextStream
strTextStream = ts.ReadAll
ts.Close

Dim aryINIFileLines
aryINIFileLines = split(strTextStream, vbNewLine)

Dim intINIFileLineIndex

for intINIFileLineIndex = 0 to UBound(aryINIFileLines) - 1
if strComp(pStrSection, aryINIFileLines(intINIFileLineIndex)) = 0 then
currSec = true
end if

if currSec then
if strComp(pStrSection, aryINIFileLines(intINIFileLineIndex)) <> 0 and inStr(aryINIFileLines(intINIFileLineIndex),"]") < 1 and continueLooking then
if inStr(aryINIFileLines(intINIFileLineIndex),"=") > 0 then
Dim token
token = Split(aryINIFileLines(intINIFileLineIndex),"=")
objDictionary.Add token(0), token(1)
if objDictionary.Exists(pStrKey) then
readIniFile = token(1)
currVar = true
exit for
end if
end if
elseif strComp(pStrSection, aryINIFileLines(intINIFileLineIndex)) <> 0 and inStr(aryINIFileLines(intINIFileLineIndex),"]") > 0 then
continueLooking = false
end if
end if
next

if not currSec then
Call REPORT_MSG("readIniFile: SECTION_NOT_EXIST " & pStrSection)
readIniFile = ""
elseif not currVar then
Call REPORT_MSG("readIniFile: VARIABLE_NOT_EXIST " & pStrKey & " in " & pStrSection & " section" )
readIniFile = ""
end if

' Added 3 lines by Jun
Set ts = Nothing
Set objDictionary = Nothing
Set fso = Nothing
end function


'-----------------------------------------------------------------------------------------
' Dialog box section
'-----------------------------------------------------------------------------------------
'This function is to click Cancel button on file downloading dialog box.
'This takes care of both platform XP and 2000
'USAGE
' Call Click_DownloadImage("Export Table to PDF Format", 0)
' Click_CancelButtonOnFileDownloadDialog
'
' Call Click_DownloadImage("Export Table to CSV Format", 0)
' Click_CancelButtonOnFileDownloadDialog
'
Function Click_CancelButtonOnFileDownloadDialog()
functionHierarchyLevel.start("Click_CancelButtonOnFileDownloadDialog")

If Browser("hwnd:=" & hWindow).Dialog("title:=File Download").Exist(OBJECT_EXIST_TIME_OUT) Then
Browser("hwnd:=" & hWindow).Dialog("title:=File Download").WinButton("text:=Cancel", "index:=0").Click
' ElseIF Dialog("text:=File Download", "Location:=1", "nativeclass:=#32770").Exist(OBJECT_EXIST_TIME_OUT) Then
' Dialog("title:=File Download").Dialog("title:=File Download").WinButton("text:=Cancel", "index:=0").Click
Else
Dim ParentDialogDesc , ChildDialogDesc, WinButtonDesc
Set ParentDialogDesc = Description.Create()
ParentDialogDesc("text").Value = "File Download"
ParentDialogDesc("location").Value = "0"
ParentDialogDesc("nativeclass").Value = "#32770"

Set ChildDialogDesc = Description.Create()
ChildDialogDesc("text").Value = "File Download"
ChildDialogDesc("location").Value = "1"
ChildDialogDesc("nativeclass").Value = "#32770"

' Dialog(ParentDialogDesc).Dialog(ChildDialogDesc).WinButton("text:=Cancel", "index:=0").Click
Set ParentDialogDesc = Nothing
Set ChildDialogDesc = Nothing
Set WinButtonDesc = Description.Create()
WinButtonDesc("nativeclass").Value = "Button"
WinButtonDesc("text").Value = "Cancel"
'Click on the "Download" link to bring up a Windows dialog, then cancel it
Dialog(ParentDialogDesc).Dialog(ChildDialogDesc).WinButton(WinButtonDesc).Click

End If

functionHierarchyLevel.fend("Click_CancelButtonOnFileDownloadDialog")
End Function



'-----------------------------------------------------------------------------------------
' QTP Data Table section
'-----------------------------------------------------------------------------------------
'Verify_ExcelWorksheetsIdentical
' Function to compare two Excel sheets (this is created to verify all KPI vlaues) ........................Venkat 03-23-06
'
' HiSTORY
' 08/16/2006 Jun Moved and renamed Verify_DtSheets_Equal function to utility. This should not be in webBroser.vbs.
' Modified it to use Excel VBA. This way, you don't have to care of format. An Excel file is an Excel file.
Function Verify_ExcelWorksheetsIdentical(pStrExcelFile1Name, pIntExcelFile1WorksheetIndex, pStrExcelFile2Name, pIntExcelFile2WorksheetIndex)

'File existance check
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

If Not fso.FileExists(pStrExcelFile1Name) Then
Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: File Not Found", _
"Verify_ExcelWorksheetsIdentical: Could not find '" & pStrExcelFile1Name & "'")
Verify_ExcelWorksheetsIdentical = FAIL
Set fso = Nothing
Exit Function
End If

If Not fso.FileExists(pStrExcelFile1Name) Then
Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: File Not Found", _
"Verify_ExcelWorksheetsIdentical: Could not find '" & pStrExcelFile2Name & "'")
Verify_ExcelWorksheetsIdentical = FAIL
Set fso = Nothing
Exit Function
End If

Set fso = Nothing

Dim anyFailure
anyFailure = False

Dim objExcel
Set objExcel = createobject("Excel.Application")
objExcel.Visible = true

Dim objWorkbook1, objWorkbook2
Set objWorkbook1 = objExcel.Workbooks.Open(pStrExcelFile1Name,, True)
Set objWorkbook2 = objExcel.Workbooks.Open(pStrExcelFile2Name,, True)

Dim objWorkSheet1, objWorkSheet2
Set objWorkSheet1 = objWorkbook1.Worksheets(pIntExcelFile1WorksheetIndex)
Set objWorkSheet2 = objWorkbook2.Worksheets(pIntExcelFile2WorksheetIndex)

Const xlCellTypeLastCell = 11

Dim intWorksheet1RowCount, intWorksheet1ColumnCount, intWorksheet2RowCount, intWorksheet2ColumnCount
intWorksheet1RowCount = objWorkSheet1.Cells.SpecialCells(xlCellTypeLastCell).Row
intWorksheet1ColumnCount = objWorkSheet1.Cells.SpecialCells(xlCellTypeLastCell).Column
intWorksheet2RowCount = objWorkSheet2.Cells.SpecialCells(xlCellTypeLastCell).Row
intWorksheet2ColumnCount = objWorkSheet2.Cells.SpecialCells(xlCellTypeLastCell).Column

'Verify row count and column count
If intWorksheet1RowCount <> intWorksheet2RowCount Then
Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: differnt row count", _
"Verify_ExcelWorksheetsIdentical: differnt row count. '" & _
pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' shows '" & intWorksheet1RowCount & "' and '" & _
pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' shows '" & intWorksheet2RowCount & "'")
anyFailure = True
End If
If intWorksheet1ColumnCount <> intWorksheet2ColumnCount Then
Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: differnt column count", _
"Verify_ExcelWorksheetsIdentical: differnt column count. '" & _
pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' shows '" & intWorksheet1ColumnCount & "' and '" & _
pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' shows '" & intWorksheet2ColumnCount & "'")
anyFailure = True
End If

Dim dataDifferencesCount
dataDifferencesCount = 0

Dim columnIndex, rowIndex

For rowIndex = 1 To intWorksheet1RowCount
For columnIndex = 1 To intWorksheet1ColumnCount
If Trim(objWorkSheet1.Cells(rowIndex, columnIndex).Value) = Trim(objWorkSheet2.Cells(rowIndex, columnIndex).Value) Then
Call REPORT_PASS("Verify_ExcelWorksheetsIdentical: (row=" & rowIndex & ", column=" & columnIndex & ") Verified", _
pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' shows '" & objWorkSheet1.Cells(rowIndex, columnIndex).Value & "' and '" & _
pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' shows '" & objWorkSheet2.Cells(rowIndex, columnIndex).Value & "'")
Else
dataDifferencesCount = dataDifferencesCount + 1
Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: data different (row=" & rowIndex & ", column=" & columnIndex & ")", _
"Verify_ExcelWorksheetsIdentical: detected data difference(row=" & rowIndex & ", column=" & columnIndex & ") '" & _
pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' shows '" & objWorkSheet1.Cells(rowIndex, columnIndex).Value & "' and '" & _
pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' shows '" & objWorkSheet2.Cells(rowIndex, columnIndex).Value & "'")
End If
Next
Next

If dataDifferencesCount = 0 And Not anyFailure Then
Call REPORT_PASS("Verify_ExcelWorksheetsIdentical Passed", _
pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' and '" & _
pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' are indentical")
Verify_ExcelWorksheetsIdentical = PASS
Else
Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: Failed with " & dataDifferencesCount & " data difference(s)", _
"Verify_ExcelWorksheetsIdentical: has detected " & dataDifferencesCount & " data difference(s)" & _
pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' and '" & _
pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' are not same")
Verify_ExcelWorksheetsIdentical = FAIL
End If


objExcel.Workbooks.close
Set objWorkbook1 = Nothing
Set objWorkbook2 = Nothing

Set objWorkSheet1 = Nothing
Set objWorkSheet2 = Nothing

objExcel.Quit
Set objExcel = Nothing


'------------------------------------------------
' Here is code that is implemented by using QTP data table.
' This has a limitation: the first row can not be verified

' Dim EXCEL_FILE1_, EXCEL_FILE2_
' EXCEL_FILE1_ = "ExcelFile1"
' EXCEL_FILE2_ = "ExcelFile2"
'
' Call DataTable.AddSheet(EXCEL_FILE1_)
' Call DataTable.AddSheet(EXCEL_FILE2_)
' Call DataTable.ImportSheet(pStrExcelFile1Name ,pIntExcelFile1WorksheetIndex , EXCEL_FILE1_)
' Call DataTable.ImportSheet(pStrExcelFile2Name ,pIntExcelFile2WorksheetIndex , EXCEL_FILE2_)
'
' 'Verify row count and column count
' If DataTable.GetSheet(EXCEL_FILE1_).GetRowCount <> DataTable.GetSheet(EXCEL_FILE2_).GetRowCount Then
' Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: differnt row count", _
' "Verify_ExcelWorksheetsIdentical: differnt row count. '" & _
' pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' shows '" & DataTable.GetSheet(EXCEL_FILE1_).GetRowCount & "' and '" & _
' pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' shows '" & DataTable.GetSheet(EXCEL_FILE2_).GetRowCount & "'")
' Verify_ExcelWorksheetsIdentical = FAIL
' Exit Function
' End If
' If DataTable.GetSheet(EXCEL_FILE1_).GetParameterCount <> DataTable.GetSheet(EXCEL_FILE2_).GetParameterCount Then
' Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: differnt column count", _
' "Verify_ExcelWorksheetsIdentical: differnt column count. '" & _
' pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' shows '" & DataTable.GetSheet(EXCEL_FILE1_).GetParameterCount & "' and '" & _
' pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' shows '" & DataTable.GetSheet(EXCEL_FILE2_).GetParameterCount & "'")
' Verify_ExcelWorksheetsIdentical = FAIL
' Exit Function
' End If
'
'
' Dim dataDifferencesCount
' dataDifferencesCount = 0
'
' Dim columnIndex, rowIndex
'
' For rowIndex = 1 To DataTable.GetSheet(EXCEL_FILE1_).GetRowCount
' Call DataTable.SetCurrentRow(rowIndex)
' For columnIndex = 1 To DataTable.GetSheet(EXCEL_FILE1_).GetParameterCount
' If Trim(DataTable.Value(columnIndex, EXCEL_FILE1_)) = Trim(DataTable.Value(columnIndex, EXCEL_FILE2_)) Then
' Call REPORT_PASS("Verify_ExcelWorksheetsIdentical: (row=" & rowIndex & ", column=" & columnIndex & ") Verified", _
' pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' shows '" & DataTable.Value(columnIndex, EXCEL_FILE1_) & "' and '" & _
' pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' shows '" & DataTable.Value(columnIndex, EXCEL_FILE2_) & "'")
' Else
' dataDifferencesCount = dataDifferencesCount + 1
' Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: data different (row=" & rowIndex & ", column=" & columnIndex & ")", _
' "Verify_ExcelWorksheetsIdentical: detected data difference(row=" & rowIndex & ", column=" & columnIndex & ") '" & _
' pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' shows '" & DataTable.Value(columnIndex, EXCEL_FILE1_) & "' and '" & _
' pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' shows '" & DataTable.Value(columnIndex, EXCEL_FILE2_) & "'")
' End If
' Next
' Next
'
' If dataDifferencesCount = 0 Then
' Call REPORT_PASS("Verify_ExcelWorksheetsIdentical Passed", _
' pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' and '" & _
' pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' are indentical")
' Verify_ExcelWorksheetsIdentical = PASS
' Else
' Call REPORT_FAILURE_NO_IMAGE("Verify_ExcelWorksheetsIdentical: Failed with " & dataDifferencesCount & " data difference(s)", _
' "Verify_ExcelWorksheetsIdentical: has detected " & dataDifferencesCount & " data difference(s)" & _
' pStrExcelFile1Name & "(" & pIntExcelFile1WorksheetIndex & ")' and '" & _
' pStrExcelFile2Name & "(" & pIntExcelFile2WorksheetIndex & ")' are not same")
' Verify_ExcelWorksheetsIdentical = FAIL
' End If

End Function


'-----------------------------------------------------------------------------------------
' ATSD Temp Folder section
'-----------------------------------------------------------------------------------------
Function CreateATSDTempFolder()
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(ATSD_TEMP_FOLDER) Then
fso.CreateFolder(ATSD_TEMP_FOLDER)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"DeleteOldATSDTempFolder created a folder", _
"DeleteOldATSDTempFolder created a folder as '" & ATSD_TEMP_FOLDER & "'")
End If

Set fso = Nothing

End Function

Function DeleteOldATSDTempFolder()

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

'Look for files which are older than days old specified in ATSD_TEMP_FOLDER_DELETE_DAY and delete them.
Dim objFolder
Set objFolder = fso.GetFolder(ATSD_TEMP_FOLDER)
Dim objFiles
Set objFiles = objFolder.Files
Dim objFile
Dim blnNeedToDelete
blnNeedToDelete = false
For Each objFile in objFiles
If DateDiff("d", objFile.DateCreated, Date) > ATSD_TEMP_FOLDER_DELETE_DAY Then
blnNeedToDelete = True
objFile.Delete
End If
Next

If blnNeedToDelete Then
Call REPORT_MSG2("DeleteOldATSDTempFolder deleted all old files", "DeleteOldATSDTempFolder deleted all old files in '" & ATSD_TEMP_FOLDER & "'")
End If

Set fso = Nothing
Set objFolder = Nothing
Set objFiles = Nothing
Set objFile = Nothing

End Function

Function DeleteFile(pStrFile1Name)
'File existance check
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

If Not fso.FileExists(pStrExcelFile1Name) Then
Call REPORT_FAILURE_NO_IMAGE("DeleteFile: File Not Found", _
"DeleteFile: Could not find '" & pStrExcelFile1Name & "'")
DeleteFile = FAIL
Set fso = Nothing
Exit Function
End If

fso.DeleteFile(pStrFile1Name)

Set fso = Nothing

End Function


Function File_Exist(filename)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
File_Exist = fso.FileExists(filename)
Set fso = Nothing
End Function

Function Verify_File_Exist(filename)
If File_Exist(filename) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_File_Exist", _
"File found: File name = '" & filename & "'"
Verify_File_Exist = PASS
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micFail, _
"Verify_File_Exist", _
"File Not Found: File name = '" & filename & "'"
Verify_File_Exist = FAIL
End If
End Function

Function Verify_File_NotFound(filename)
If File_Exist(filename) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micFail , _
"Verify_File_NotFound", _
"File found: File name = '" & filename & "'"
Verify_File_NotFound= FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_File_NotFound", _
"File Not Found: File name = '" & filename & "'"
Verify_File_NotFound= PASS
End If
End Function

Function Folder_Exist(folderName)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Folder_Exist = fso.FolderExists(folderName)
Set fso = Nothing
End Function

Function DeleteFolder(pStrFolderName)
'Folder existance check
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

If Not fso.FolderExists(pStrFolderName) Then
Call REPORT_FAILURE_NO_IMAGE("DeleteFolder: Folder Not Found", _
"DeleteFolder: Could not find '" & pStrFolderName & "'")
DeleteFolder = FAIL
Set fso = Nothing
Exit Function
End If

fso.DeleteFolder(pStrFolderName)

Set fso = Nothing

End Function

Function Verify_Folder_Exist(folderName)
If Folder_Exist(folderName) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_Folder_Exist", _
"Folder found: Folder name = '" & folderName & "'"
Verify_Folder_Exist = PASS
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micFail, _
"Verify_Folder_Exist", _
"Folder Not Found: Folder name = '" & folderName & "'"
Verify_Folder_Exist = FAIL
End If
End Function

Function Verify_Folder_NotFound(folderName)
If Folder_Exist(folderName) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micFail , _
"Verify_Folder_NotFound", _
"Folder found: Folder name = '" & folderName & "'"
Verify_Folder_NotFound= FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_Folder_NotFound", _
"Folder Not Found: Folder name = '" & folderName & "'"
Verify_Folder_NotFound= PASS
End If
End Function



'If pStrCommandPromptTitle is set, then use it.
'If not, use windir environmental variable
Function WaitWhileCommandPromptShown(pStrCommandPromptTitle)

Dim strTargetCommandPromptTitle_

If IsNull(pStrCommandPromptTitle) or pStrCommandPromptTitle = "" Then
'Get a title of command prompt window from environment variable
Dim oShell_, oWshProcessEnv_
Set oShell_ = CreateObject("WScript.Shell")
Set oWshProcessEnv_ = oShell_.Environment("process")

Dim strWinDir_
strWinDir_ = oWshProcessEnv_("windir")

Set oWshProcessEnv_ = Nothing
Set oShell_ = Nothing

'command prompt title string has to be escaped by \
' "C:\\WINDOWS\\system32\\cmd\.exe" ' If you use Windows XP
' "C:\\WINNT\\system32\\cmd\.exe" ' If you use Windows 2000
strTargetCommandPromptTitle_ = Replace(strWinDir_, "\", "\\") & "\\system32\\cmd\.exe"
Else
strTargetCommandPromptTitle_ = Replace(pStrCommandPromptTitle, "\", "\\")
End If

' need a solution to handle MS-DOS windows, line below does not work
Reporter.Filter = rfDisableAll
While Window("regexpwndtitle:=" & strTargetCommandPromptTitle_).Exist(WINDOW_EXIST_TIME_OUT)
Call wait(3)
Wend
End Function

Function OpenOldHTMLTAndE()
Dim url
'Max, 05/18: added "classic" since this is how you get to old T&E now
url = CORE_APPLICATION_URL & "?urlVer=3&task=classicTimeAndExpense"

Call Open_URL(url)

Set_Window 1

If Link_Exists(" Entry", 0) Then
Call Click_Link (" Entry", 0)
End if

OpenOldHTMLTAndE = PASS
End Function

'Call Set_Picker_Recipients("Select Recipients", 0, Array("chung, buu", "chung, gigi"))
'Call Set_Picker_Recipients("Select Recipients", 1, Array("Maranyan, Zemfira", "Olson, Mishelle"))

' Set_Picker_Recipients
' DESCRIPTION
' This function will set the recipients in a request in To (Unrestricted), To (Restricted), and CC
'
'PARAMETERS
' pStrPickerImageName --> either Select Recipients, or Select CC Recipients
' pIntIndex --> for To (Unrestricted), use Select Recipients with index 0, and for To (Restricted) use 1.
'
'Usage
' To set users in To (Unrestricted):
' Call Set_Picker_Recipients("Select Recipients", 0, Array("chung, buu", "face, smiley"))
'
' To set users in To (Restricted):
' Call Set_Picker_Recipients("Select Recipients", 1, Array("Toor, Sharan", "owner, resource"))
'
' To set users in CC:
' Call Set_Picker_Recipients("Select CC Recipients", 0, Array("Toor, Sharan", "owner, resource"))

Function Set_Picker_Recipients(pStrPickerImageName, pIntIndex, pArryRecipients)

Dim filterName

If Click_Image(pStrPickerImageName, pIntIndex) <> PASS then
Set_Picker_Recipients = FAIL
Call CaptureWindowImage("Set_Picker_Recipients Couldn't click image '" & pStrPickerImageName & "'")
Exit Function
End If

'Have to think about "All Project Owners"
If pStrPickerImageName = "Select CC Recipients" Then
filterName = "Active Users"
Else
filterName = "All Resource Pool Owners"
If not ComboBoxItem_Exists_ByDataName("ixn_pickMultiUser_filterEntry", 0, filterName) Then
filterName = "All Project Owners"
End If
End If

If Set_ComboBoxItem_ByName ("ixn_pickMultiUser_filterEntry", 0, filterName) = PASS Then
Call Click_Link("Find", 0)
If Link_Exists ("Show All", 0) Then
Call Click_Link ("Show All", 0)
End If
Call Click_DataLinks(pArryRecipients)
Call Click_Link("OK", 0)
Set_Picker_Recipients = PASS
Else
Set_Picker_Recipients = FAIL
End If

End Function 'The End Of Set_Picker_Recipients Function


'added by Alex 6/25/2007
' example: Checking_Free_Space_on_Hard_Drive (20, "c") -checks that free space on c: is more then 20 GB
' example: Checking_Free_Space_on_Hard_Drive (7.25, "D")
' function submits error:
' -if free space is less then minimum
' -if drive is other then hard drive
' -if drive is absent
' returns "PASS" or "FAIL"
Function Checking_Free_Space_on_Hard_Drive (pFreeSpaceMinimum, pHardDriveLetter)

Dim objFileSystem, objDriverSet, objHardDrive, objHardDriveInformation,_
FreeSpaceOnHardDriveInBytes, FreeSpaceOnHardDriveInGBs, doesDriveExist, HardDriveType

pHardDriveLetter=UCase(pHardDriveLetter)

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objDriverSet = objFileSystem.Drives

doesDriveExist=false
For Each objHardDrive in objDriverSet
If (pHardDriveLetter = objHardDrive.DriveLetter)Then
doesDriveExist=true
Exit For
End If
Next
If doesDriveExist=false Then
Call REPORT_FAILURE_NO_IMAGE("Checking free space on hard drive.", "Drive " & pHardDriveLetter & ": is not found!")
Checking_Free_Space_on_Hard_Drive = "FAIL"
Exit Function
End If

Set objHardDriveInformation = objFileSystem.GetDrive(pHardDriveLetter)
HardDriveType=objHardDriveInformation.DriveType
If (HardDriveType<>2) Then
Call REPORT_FAILURE_NO_IMAGE("Checking free space on hard drive.", pHardDriveLetter & ": is not hard drive!")
Checking_Free_Space_on_Hard_Drive = "FAIL"
Exit Function
End If

FreeSpaceOnHardDriveInBytes=objHardDriveInformation.FreeSpace
FreeSpaceOnHardDriveInGBs=Round(FreeSpaceOnHardDriveInBytes/(1024*1024*1024), 2)
If (FreeSpaceOnHardDriveInGBs < pFreeSpaceMinimum) Then
Call REPORT_FAILURE_NO_IMAGE("Checking free space on hard drive.", _
"Free space on " & pHardDriveLetter & ": is" & FreeSpaceOnHardDriveInGBs & "GB." & vbCr & "Must be more then " &pFreeSpaceMinimum & "GB")
Checking_Free_Space_on_Hard_Drive = "FAIL"
Exit Function
End If

Call REPORT_MSG2("Checking free space on hard drive.", _
"Free space on " & pHardDriveLetter & ": is" & FreeSpaceOnHardDriveInGBs & "GB." & vbCr & "Minimum free space is " & pFreeSpaceMinimum & "GB")
Checking_Free_Space_on_Hard_Drive = "PASS"

End Function

No comments: