webbrowser

Option Explicit
dim pStrComboboxName
Public hWindow, wHandle1, wHandle2, wHandle3
public Table_Verify ' Table_Verify flag helps in GetRowIndex_AccordingValue_InTable by reducing number of calls to WebTable_Exists function and making scripts faster
Table_Verify = True
'wHandle1 = 0
'wHandle2 = 0
'wHandle3 = 0
'^^^^ Max, 12/01/04: we might want to change it later, but for now it looks good. hWindow is used in scripts and stores information about current window
'^^^^ Other variables are used to store information about first, second and third windows.

'There are several types of fuctions.
'---------------------------------------------------------------------------------------------
' EXISTS section: we verify that all objects are on the page, but do not fail script
' If object not on the page, we simply return specific code and then it is up to test script creator to decide what to do with it.
' main use is to verify that object NOT shown on the page and also to build logic around what is shown on the page
'RETURN
' True : If the object specified by Name and Index exists
' False : If the object specified by Name and Index does NOT exist
'
' There is QTP limitation that if there is a object on a page, Exist method (ex: Link.Exist) can not identify Index parameter.
' A page that has 2 Projects link objects.
' Browser("title:=.*").Page("title:=.*").Link("Name:=Projects", "Index:=0").Exist -> True <- Expected behavior
' Browser("title:=.*").Page("title:=.*").Link("Name:=Projects", "Index:=1").Exist -> True <- Expected behavior
' Browser("title:=.*").Page("title:=.*").Link("Name:=Projects", "Index:=2").Exist -> False <- Expected behavior
' Browser("title:=.*").Page("title:=.*").Link("Name:=Projects").Exist -> False
' A page that has only 1 Projects link object.
' Browser("title:=.*").Page("title:=.*").Link("Name:=Projects", "Index:=0").Exist -> True <- Expected behavior
' Browser("title:=.*").Page("title:=.*").Link("Name:=Projects", "Index:=1").Exist -> True <- UNEXPECTED!!
' Browser("title:=.*").Page("title:=.*").Link("Name:=Projects", "Index:=2").Exist -> True <- UNEXPECTED!!
' ...
' Browser("title:=.*").Page("title:=.*").Link("Name:=Projects").Exist -> True
'
' What is impact
' Let's say the Exists function is defined as below.
' Function Link_Exists(pStrName, pIntIndex)
' Link_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("Name:=" & pStrName, "Index:=" & pIntIndex).Exist
' End Function
' The Exists function always returns True regardless of the Index if there is only 1 link object on the page.
' This fact impacts Count functions and inconsistent behavior
'
' Here is workaround
' Use Link.Exist method without Index parameter.
' ex) Browser("title:=.*").Page("title:=.*").Link("Name:=Projects").Exist
' The method returns:
' True if there is only 1 object on the page.
' False if there is no object or more than 1 object on the page.
' If there is only 1 object and pIntIndex is set 0, this Exist function returns True
' If there is only 1 object and pIntIndex is NOT set 0, this Exist function returns False
' In the other case, use Link.Exist method again with Index parameter to make sure the object is there.
'---------------------------------------------------------------------------------------------
' NO TRANSLATION for 'Data' fucntions
'---------------------------------------------------------------------------------------------
' VERIFY EXISTS section: we verify that all objects are on the page, and fail script if object not found
' main use: to verify that object is shown on the page.
' to a degree, it replaces QTP checkpoint functionality
'---------------------------------------------------------------------------------------------
' VERIFY_NOTFOUND section: we verify that objects is NOT on the page, and fail script if object IS found
' main use: to verify that object is NOT shown on the page.
' to a degree, it replaces QTP checkpoint functionality
'---------------------------------------------------------------------------------------------
' COUNT functions: counting number of objects on the page
'---------------------------------------------------------------------------------------------
' Get functions: counting number of objects on the page
'---------------------------------------------------------------------------------------------
' SET Function section: To set the value to the field
' for all SET functions translation MUST be done from scritps. Functions themself don't do translation
' by the way: OPEN ISSUE: translation in this section?....
'RETURN
' PASS
' FAIL
'---------------------------------------------------------------------------------------------
' CLICK functions: we click on everything that can be clicked
'---------------------------------------------------------------------------------------------
dim browser_title
dim page_title
dim Error_Flag

'OPEN_ISSUE ***************
' Need to handl these 2 parameters in order to get quick response
page_title=".*"
browser_title=".*"
'OPEN_ISSUE ***************

'Const NO_ERROR = "NO_ERROR"
'Const ERROR_SHOWN = "ERROR_SHOWN"
'Represent Error codes for Fail_If_Error_Shown functions.
Dim NO_ERROR
Dim ERROR_SHOWN
NO_ERROR = "NO_ERROR"
ERROR_SHOWN = "ERROR_SHOWN"
Error_Flag=NO_ERROR 'also can be ERROR_SHOWN

'Public MAX_RESPONSE_TIME ' MAX_RESPONSE_TIME has been replaced with AnalyzePerformanceClass

'---------------------------------------------------------------------------------------------
' UTILITY functions: everything we might need in this library
'---------------------------------------------------------------------------------------------
Dim analyzePerformance
Class AnalyzePerformanceClass
Private dtmStartTime
Private dtmEndTime

Public Function start()
dtmStartTime = now()
End Function

Public Function aend() '"end" is a reserved keyword.
dtmEndTime = now()

Dim duration_
duration_ = DateDiff("s", dtmStartTime, dtmEndTime)

If (URL_FLAG = "CORE" and duration_ >= ANALYZE_PERFORMANCE_CORE_MAX_WAIT_TIME) _
Or (URL_FLAG <> "CORE" and duration_ >= ANALYZE_PERFORMANCE_PMBI_MAX_WAIT_TIME) Then
Call REPORT_FAILURE2("Link/Image/Button click took too long: ", _
"AnalyzePerformanceClass: The current action took " & duration_ & " second. The start analyzing time is " & dtmStartTime & " and the finish analyzing time is " & dtmEndTime)
End If

End Function

End Class

Set analyzePerformance = new AnalyzePerformanceClass


Function Check_For_Error_On_The_Page()

' This is a temprary workaround.
If CHECK_FOR_ERROR_ON_THE_PAGE_FUNCTION_ENABLE or URL_FLAG = "SP" Then
' If CHECK_FOR_ERROR_ON_THE_PAGE_FUNCTION_ENABLE Then


dim error_url
Error_Flag=NO_ERROR ' will work on it later
' if error is on the page, get URL from browser and send it to Reporter as message, not warning..
' We will be checking for strings/objects listed below
' if any of them is found, then we set Error_Flag to ERROR_SHOWN and also capture and report to results URL on which we recieved this error
' at this point this function is only for 'bad' errors, but I am thinking it should also support all iFrames - this way we get more flexebility
' and can allow wider usage of this function. if we do it, we would have to call this funciton only from FAIL_IF_ERROR_SHOWN and
' FAIL_IF_ERROR_NOT_SHOWN functions - this will greatly speed up script execution.
'---------------> "Primavera encountered an unexpected error"
'---------------> "Error"
'---------------> "Internal Error"
if Not ( Text_Exists("Primavera encountered an unexpected error",0)_
or Text_Exists("Error",0)_
or Text_Exists("Internal Error",0) ) then
Error_Flag = NO_ERROR
else ' if there is an error on the page, how can I get it? -- do i do 'IF' for single error and then have error-type specific code to capture error message?
Error_Flag = ERROR_SHOWN
' get and report current URL, because we have error
error_url = Get_URL()
Call REPORT_MSG("Error is shown on the page. Current URL is: " & error_url)
end if
Check_For_Error_On_The_Page=Error_Flag
End If
End Function

function Fail_If_Error_Shown (msg)
If CHECK_FOR_ERROR_ON_THE_PAGE_FUNCTION_ENABLE Then
Check_For_Error_On_The_Page ' do we need to do additional error check here?? -- this all depends on how long it takes to do error verification
' currently, we do error verification (or supposed to do) with every action that refreshes the page, but it miht be too expensive in terms of
' script duration. we might want to do 'on call' error checks. this is why for now I (Max) see that this function fits here.
If (Error_Flag=ERROR_SHOWN) Then
Call REPORT_FAILURE2("Unexpected error on the page", _
msg)
End If
End If
End Function

Function Fail_If_Error_NotShown (msg)
If CHECK_FOR_ERROR_ON_THE_PAGE_FUNCTION_ENABLE Then
Check_For_Error_On_The_Page ' do we need to do additional error check here?? -- this all depends on how long it takes to do error verification
' currently, we do error verification (or supposed to do) with every action that refreshes the page, but it miht be too expensive in terms of
' script duration. we might want to do 'on call' error checks. this is why for now I (Max) see that this function fits here.
If (Error_Flag=NO_ERROR) Then
Call REPORT_FAILURE2("Expecting error on the page, but no error shown", _
msg)
End If
End If
End Function



'---------------------------------------------------------------------------------------------
' Link Object section
'---------------------------------------------------------------------------------------------
'No need to translate
Function DataLink_Exists(pStrLinkText, pIntLinkIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("Name:=" & pStrLinkText).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntLinkIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntLinkIndex = 0 Then
DataLink_Exists = True
Exit Function
End If
'If there is only 1 object and pIntLinkIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntLinkIndex <> 0 Then
DataLink_Exists = False
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
DataLink_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("Name:=" & pStrLinkText, "Index:=" & pIntLinkIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function
Function DataLink_Exist(pStrLinkText, pIntLinkIndex) ' inserted by Max to avoid failures because of typos
DataLink_Exist = DataLink_Exists(pStrLinkText, pIntLinkIndex)
End Function

Function Link_Exists(pStrLinkText, pIntLinkIndex)
dim translated_name_
translated_name_ = Local_Text(pStrLinkText)
Link_Exists = DataLink_Exists(translated_name_, pIntLinkIndex)
End Function
Function Link_Exist(pStrLinkText, pIntLinkIndex) ' inserted by Max to avoid failures because of typos
Link_Exist = Link_Exists(pStrLinkText, pIntLinkIndex)
End Function

Function Verify_Link_Exists(pStrLinkText, pIntLinkIndex)
If Link_Exists (pStrLinkText, pIntLinkIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_Link_Exists", _
"Link found: link name = '" & pStrLinkText & "' link index ='" & pIntLinkIndex & "'"
Verify_Link_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_Link_Exists", _
"Link Not Found: link name = '" & pStrLinkText & "' link index ='" & pIntLinkIndex & "'")
Verify_Link_Exists = FAIL
End If
End Function
Function Verify_Link_Exist(pStrLinkText, pIntLinkIndex) ' inserted by Max to avoid failures because of typos
Verify_Link_Exist = Verify_Link_Exists(pStrLinkText, pIntLinkIndex)
End Function

' NO TRANSLATION for 'Data' fucntions
Function Verify_DataLink_Exists(pStrLinkText, pIntLinkIndex)
If DataLink_Exists (pStrLinkText, pIntLinkIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Data Link found: " & pStrLinkText ,""
Verify_DataLink_Exists = PASS
Else
Call REPORT_FAILURE2("Data Link not found: " & pStrLinkText, _
"Data Link not found: " & pStrLinkText)
Verify_DataLink_Exists = FAIL
End If
End Function
Function Verify_DataLink_Exist(pStrLinkText, pIntLinkIndex) ' inserted by Max to avoid failures because of typos
Verify_DataLink_Exist = Verify_DataLink_Exists(pStrLinkText, pIntLinkIndex)
End Function

Function Verify_Link_NotFound(pStrLinkText, pIntLinkIndex)
If Link_Exists (pStrLinkText, pIntLinkIndex) Then
Call REPORT_FAILURE2("Verify_Link_NotFound", _
"Link found: link name = '" & pStrLinkText & "' link index ='" & pIntLinkIndex & "'")
Verify_Link_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_Link_NotFound", _
"Link Not Found: link name = '" & pStrLinkText & "' link index ='" & pIntLinkIndex & "'"
Verify_Link_NotFound = PASS
End If
End Function

' NO TRANSLATION for 'Data' fucntions
Function Verify_DataLink_NotFound(pStrLinkText, pIntLinkIndex)
If DataLink_Exists (pStrLinkText, pIntLinkIndex) Then
Call REPORT_FAILURE2("Data Link found: " & pStrLinkText, _
"Data Link found: " & pStrLinkText)
Verify_DataLink_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Data Link not found: " & pStrLinkText ,""
Verify_DataLink_NotFound = PASS
End If
End Function

Function Count_Link (pStrName)
dim i_
i_=0
while (Link_Exists(pStrName, i_))
i_=i_+1
wend
Count_Link = i_
End Function
function Count_Links(pStrName)
Count_Links = Count_Link (pStrName)
end function

'No need to translate
Function Count_DataLink (pStrName)
dim i_
i_=0
while (DataLink_Exists(pStrName, i_))
i_=i_+1
wend
Count_DataLink = i_
End Function
function Count_DataLinks(pStrName)
Count_Links = Count_DataLink (pStrName)
end function

Function Click_Link(pStrLinkText, pIntLinkIndex)
dim translated_name_
' dim ret_
translated_name_ = Local_Text(pStrLinkText)
'Msgbox translated_name_
If Link_Exists (pStrLinkText, pIntLinkIndex) Then ' this has to be Link_Exists because the parameter is translated in the function.
analyzePerformance.start
Reporter.Filter = rfDisableAll
' ret_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("Name:="& translated_name_, "Index:=" & pIntLinkIndex).Click 'Deleted by Jun: Click method does not return any value at any time.
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("Name:="& translated_name_, "Index:=" & pIntLinkIndex).Click
Reporter.Filter = rfEnableAll
Call REPORT_MSG2("Click_Link " & pStrLinkText, _
"'" & pStrLinkText & "'(translated '" & translated_name_ & "' index='" & pIntLinkIndex & "') clicked")
Click_Link = PASS

Sync_Page 'Browser("hwnd:=" & hWindow).Sync

analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Else
Call REPORT_FAILURE2("Click_Link: Link not found: " & pStrLinkText ,"'" & pStrLinkText & "' (translated '" & translated_name_ & "'). Index was: " & pIntLinkIndex & " not found")
Click_Link = FAIL
End If
End Function

'This function is used for a link that downloads a file
' e.g. "Check Out" link in Collaboration
' Windows(IE) blocks a downloading caused by event-based-click so far and in fact we use event-based-click in QTP.
Function Click_DownloadLink(pStrLinkText, pIntLinkIndex)
'If the setting is 1: Events, IE blocks the popup dialog.
Setting.WebPackage("ReplayType") = 2
Call Click_Link(pStrLinkText, pIntLinkIndex)
Setting.WebPackage("ReplayType") = 1
End Function

Function Click_DataLink(pStrLinkText, pIntLinkIndex)
' dim ret_
If DataLink_Exists (pStrLinkText, pIntLinkIndex) Then
analyzePerformance.start
Reporter.Filter = rfDisableAll
' ret_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("text:="& pStrLinkText, "Index:=" & pIntLinkIndex).Click 'Deleted by Jun: Click method does not return any value at any time.
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("text:="& pStrLinkText, "Index:=" & pIntLinkIndex).Click
Reporter.Filter = rfEnableAll
Call REPORT_MSG2("Click_DataLink " & pStrLinkText, "'" & pStrLinkText & "' clicked")
Click_DataLink = PASS
Sync_Page

analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Else
Call REPORT_FAILURE2("Click_DataLink " & pStrLinkText ,"Link name: " & pStrLinkText & "Index was: " & pIntLinkIndex & " not found" )
Click_DataLink = FAIL
End If
End Function

'EXAMPLE
' arrayLinkTexts_ = Array("Projects", "Clients", "Opportunities")
' Call Verify_Links_Exists(arrayLinkTexts_)
Function Verify_Links_Exists(pArrayLinkTexts)
Dim linkText_
For Each linkText_ in pArrayLinkTexts
Call Verify_Link_Exists(linkText_, 0)
Next
End Function
Function Verify_Links_Exist(pArrayLinkTexts)
Verify_Links_Exists(pArrayLinkTexts)
End Function
Function Verify_DataLinks_Exists(pArrayDataLinkTexts)
Dim linkText_
For Each linkText_ in pArrayDataLinkTexts
Call Verify_DataLink_Exists(linkText_, 0)
Next
End Function
Function Verify_DataLinks_Exist(pArrayLinkTexts)
Verify_DataLinks_Exists(pArrayLinkTexts)
End Function
'EXAMPLE
' arrayLinkTexts_ = Array("Projects", "Find", "New Project")
' Call Click_Links(arrayLinkTexts_)
Function Click_Links(pArrayLinkTexts)
Dim linkText_
For Each linkText_ in pArrayLinkTexts
Call Click_Link(linkText_, 0)
Sync_Page
Call Fail_If_Error_Shown("Clicking on link " & linkText_ & "produced an error")
Next
End Function

'EXAMPLE
' arrayLinkTexts_ = Array("Projects", "Find", "New Project")
' Call Click_DataLinks(arrayLinkTexts_)
Function Click_DataLinks(pArrayLinkTexts)
Dim linkText_
For each linkText_ in pArrayLinkTexts
Call Click_DataLink(linkText_,0)
Sync_Page
Fail_If_Error_Shown "Clicking on data link " & linkText_ & "produced an error"
Next
End Function

Function Verify_Link_URL(pStrLinkText, pIntLinkIndex, pStrExpectedURL)
If Link_Exists (pStrLinkText, pIntLinkIndex) Then
Dim strActualURL_
strActualURL_ = Get_Link_URL(pStrLinkText, pIntLinkIndex)
If Lcase(strActualURL_) = Lcase(pStrExpectedURL) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_Link_URL", _
"Link URL is correct : link name = '" & pStrLinkText & "' link index ='" & pIntLinkIndex & "' link URL ='" & pStrExpectedURL & "'"
Verify_Link_URL = PASS
Else
Call REPORT_FAILURE2("Verify_Link_URL", _
"Link URL is Not correct : link name = '" & pStrLinkText & "' link index ='" & pIntLinkIndex & "' actual link URL ='" & strActualURL_ & "' expected link URL = '" & pStrExpectedURL & "'")

Verify_Link_URL = Fail
End If
Else

Call REPORT_FAILURE2("Verify_Link_URL", _
"Link Not Found: link name = '" & pStrLinkText & "' link index ='" & pIntLinkIndex & "'")
Verify_Link_URL = FAIL
End If
End Function

Function Get_Link_URL(pStrLinkText, pIntLinkIndex)
If Not Link_Exists (pStrLinkText, pIntLinkIndex) Then
Call REPORT_FAILURE2("Get_Link_URL", _
"Link Not Found: link name = '" & pStrLinkText & "' link index ='" & pIntLinkIndex & "'")
Get_Link_URL = ""
Exit Function
End If

Reporter.Filter = rfDisableAll
Get_Link_URL = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("Name:=" & pStrLinkText, "Index:=" & pIntLinkIndex).GetROProperty("href")
End Function

' This closes a popup window by clicking a specified link.
' The difference from combinations of Click_Link and Set_Window is:
' 1. No need for Set_Window
' 2. More stable(Click_Link calls Sync_Page that has a potential problem which page it actually sync)
' Using this function fits to a scenaio that:
' 1. Click a link that closes the current window and
' 2. The window that is just one layer below still remains open.
' If against above, this reports ERROR
' USAGE EXAMPLE
' Call Click_Link("Skills",0)
' Call Set_Window(2)
' Call Click_Link("Find",0)
' Call Click_Link("Java/HTML",0)
' ' This needs one line, only this function.
' Call Close_Active_Window_ByClickLink("Close", 0)
' ' This is what you wrote...
' ' Call Click_Link("Close", 0)
' ' Call Sync_Page(1)
' Call Click_Link("Edit",0)
Function Close_Active_Window_ByClickLink(pStrLinkText, pIntLinkIndex)

dim translated_name_
translated_name_ = Local_Text(pStrLinkText)

If Not Link_Exists(translated_name_, pIntLinkIndex) Then
Call REPORT_FAILURE("Close_Active_Window_ByClickLink: Link('" & pStrLinkText & "'(" & translated_name_ & ")) Not Found")
Close_Active_Window_ByClickLink = FAIL
Exit Function
End If

analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Link("Name:="& translated_name_, "Index:=" & pIntLinkIndex).Click

Call REPORT_MSG("Close_Active_Window_ByClickLink clicked '" & pStrLinkText & "'(" & translated_name_ & " link")

' Check the "newly active" window is loaded completed,
' Sync_Page is not used because Sync_Page can not sense where is the currently active window.
Dim formerlyCurrentlyActiveWindowHandle_
If hWindow = wHandle3 Then
hWindow = wHandle2
formerlyCurrentlyActiveWindowHandle_ = wHandle3
wHandle3 = 0
ElseIf hWindow = wHandle2 Then
hWindow = wHandle1
formerlyCurrentlyActiveWindowHandle_ = wHandle2
wHandle2 = 0
wHandle3 = 0
End If

Dim CHECK_FREQUENCY_
CHECK_FREQUENCY_ = 0.5 'second how often this function verify if the page is loaded

Dim counter
counter = 0
Do Until Browser("hwnd:=" & hWindow).Page("title:=.*").Object.readyState = "complete"
counter = counter + 1

'Time out
If (URL_FLAG = "CORE" and (counter * CHECK_FREQUENCY_) >= CORE_UI_MAX_SYNC_TIME) _
Or (URL_FLAG <> "CORE" and (counter * CHECK_FREQUENCY_) >= PMBI_MAX_SYNC_TIME) _
Then
Call REPORT_FAILURE("Close_Active_Window_ByClickLink: sync aborted", "Waited for " & counter * CHECK_FREQUENCY_ & " seconds and still the page does not get loaded.")
Exit Do
End If

Call Wait (CHECK_FREQUENCY_)

Loop

'Check if the formerly "currently active" window disapper.
Reporter.Filter = rfDisableAll
counter = 0
Do Until Not Browser("hwnd:=" & formerlyCurrentlyActiveWindowHandle_).Exist(EXIST_TIME_OUT)
counter = counter + 1

'Time out (5 seconds is used because this should not take more than that.
If (counter * CHECK_FREQUENCY_) >= 5 Then
' The window handlers is reverted back because formerlyCurrentlyActiveWindowHandle_ does not disappear!
' (if this is an array then things are much more easy...)
If hWindow = wHandle1 Then
hWindow = formerlyCurrentlyActiveWindowHandle_
wHandle2 = formerlyCurrentlyActiveWindowHandle_
ElseIf hWindow = wHandle2 Then
hWindow = formerlyCurrentlyActiveWindowHandle_
wHandle3 = formerlyCurrentlyActiveWindowHandle_
End If

Call REPORT_FAILURE("Close_Active_Window_ByClickLink: The formerly 'currently active' window(wndHandle = '" & formerlyCurrentlyActiveWindowHandle_ & "') remains open after clicking '" & pStrLinkText & "' link")
Close_Active_Window_ByClickLink = FAIL
Exit Function
End If

Call Wait (CHECK_FREQUENCY_)

Loop

Close_Active_Window_ByClickLink = PASS
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error

End Function ' Close_Active_Window_ByClickLink


'---------------------------------------------------------------------------------------------
' Button Object Section
'---------------------------------------------------------------------------------------------
Function DataButton_Exists(pStrButtonName, pIntButtonIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebButton("Name:=" & pStrButtonName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntButtonIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntButtonIndex = 0 Then
DataButton_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntButtonIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntButtonIndex <> 0 Then
DataButton_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
DataButton_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebButton("Name:=" & pStrButtonName, "Index:=" & pIntButtonIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function Button_Exists(pStrButtonName, pIntButtonIndex)
dim translated_name_
translated_name_ = Local_Text(pStrButtonName)
Button_Exists = DataButton_Exists(translated_name_, pIntButtonIndex)
End Function

Function Verify_Button_Exists(pStrButtonName, pIntButtonIndex)
If Button_Exists (pStrButtonName, pIntButtonIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_Button_Exists", _
"Button found: Button name = '" & pStrButtonName & "', Button index ='" & pIntButtonIndex & "'"
Verify_Button_Exists = PASS
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_Button_Exists", _
"Button Not found: Button name = '" & pStrButtonName & "', Button index ='" & pIntButtonIndex & "'"
Verify_Button_Exists = FAIL
End If
End Function

Function Verify_Button_NotFound(pStrButtonName, pIntButtonIndex)
If Button_Exists (pStrButtonName, pIntButtonIndex) Then
Call REPORT_FAILURE2("Verify_Button_NotFound", _
"Button found: Button name = '" & pStrButtonName & "', Button index ='" & pIntButtonIndex & "'")
Verify_Button_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_Button_NotFound", _
"Button Not found: Button name = '" & pStrButtonName & "', Button index ='" & pIntButtonIndex & "'"
Verify_Button_NotFound = PASS
End If
End Function

Function Verify_DataButton_Exists(pStrButtonName, pIntButtonIndex)
If DataButton_Exists (pStrButtonName, pIntButtonIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Data Button found: " & pStrButtonName ,"."
Verify_DataButton_Exists = PASS
Else
Call REPORT_FAILURE2("Data Button not found: " & pStrButtonName, _
"Data Button not found: " & pStrButtonName)
Verify_DataButton_Exists = FAIL
End If
End Function

Function Verify_DataButton_NotFound(pStrButtonName, pIntButtonIndex) ' open issue: pIntButtonIndex IS required...
If DataButton_Exists (pStrButtonName, pIntButtonIndex) Then
Reporter.Filter = rfEnableAll

Call REPORT_FAILURE2("Data Button found: " & pStrButtonName, _
"Data Button found: " & pStrButtonName)
Verify_DataButton_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Data Button not found: " & pStrButtonName ,"."
Verify_DataButton_NotFound = PASS
End If
End Function

Function Count_Button (pStrButtonName)
dim i_
i_=0
while (Button_Exists(pStrButtonName, i_))
i_=i_+1
wend
Count_Button = i_
End Function

Function Count_DataButton(pStrButtonName)
dim i_
i_=0
while (DataButton_Exists(pStrButtonName, i_))
i_=i_+1
wend
Count_DataButton = i_
End Function

Function Click_Button(pStrButtonName, pIntButtonIndex)
dim translated_name_
translated_name_ = Local_Text(pStrButtonName)

If Button_Exists (pStrButtonName, pIntButtonIndex) Then
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebButton("Name:="& translated_name_, "Index:=" & pIntButtonIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebButton("Name:=" & translated_name_, "Index:=" & pIntButtonIndex).Click
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & translated_name_ & "' button pushed" , _
"Click_Button function pushed'" & translated_name_ & "' button.")

Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Click_Button = PASS
Else
Call REPORT_FAILURE2("Button not found: " & translated_name_, _
"Click_Button Failed. English value was: " & pStrButtonName & ". Index was: " & pIntButtonIndex)
Click_Button = FAIL
End If
End Function

Function Click_DataButton(pStrButtonName, pIntButtonIndex)
If DataButton_Exists (pStrButtonName, pIntButtonIndex) Then
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebButton("Name:=" & pStrButtonName, "Index:=" & pIntButtonIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebButton("Name:=" & pStrButtonName, "Index:=" & pIntButtonIndex).Click
Sync_Page
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Click_DataButton = PASS
Else
Call REPORT_FAILURE2("Button not found: " & pStrButtonName, _
"Click_DataButton Failed. Index was: " & pIntButtonIndex)

Click_DataButton = FAIL
End If
End Function

'-------------------------------------------------------------------------------------------------
' Windows Button Object Section
'---------------------------------------------------------------------------------------------
' Language on this dialog does not depend on a Primavera User, but depending on PC Environment.
' At this moment, we assume PC environment is only English.
'OPEN_ISSUE **********************
'The case you need to translate is you run this scipt on the other language environment than English.
'Not depends on user locale.
'OPEN_ISSUE **********************
Function WinButton_Exists(pStrName, pIntIndex)

' Need to wait for a moment in order to let a browser show a message box.
' The issue was when a script clicks a link that pops up a messabox (e.g. "Clear Cache ..." in Option page),
' QTP can not know how long it has to wait till the message box is shown.
' As a result, QTP runs to the next step before clicking a OK button to close the box, and messing up the following.
Call Wait (2)

'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Dialog("title:=" & BROWSER_NAME).WinButton("text:=" & pStrName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntIndex = 0 Then
WinButton_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntIndex <> 0 Then
WinButton_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
WinButton_Exists = Browser("hwnd:=" & hWindow).Dialog("title:=" & BROWSER_NAME).WinButton("text:=" & pStrName , "index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Verify_WinButton_Exists(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
If WinButton_Exists (pStrName, pIntIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Button found: " & pStrName ,"."
Verify_WinButton_Exists = PASS
Else
Call REPORT_FAILURE2("Button not found: " & pStrName, _
"Button not found: " & pStrName)
Verify_WinButton_Exists = FAIL
End If
End Function

Function Click_WinButton(pStrName, pIntIndex)
If Not WinButton_Exists (pStrName, pIntIndex) Then
Call REPORT_FAILURE2("Click_WinButton " & pStrName & " not found", _
"Click_WinButton Failed. English value was: " & pStrName)
Click_WinButton = FAIL
Exit Function
End If

analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Dialog("title:=" & BROWSER_NAME).WinButton("text:=" & pStrName , "index:=" & pIntIndex).Click
Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error

Call REPORT_MSG2(pStrName & " clicked", _
"Click_WinButton '" & pStrName & "(index='" & pIntIndex & "') clicked")

Click_WinButton = PASS
End Function

'---------------------------------------------------------------------------------------------
' Image Object section
'---------------------------------------------------------------------------------------------
Function DataImage_Exists(pStrAltText, pIntImageIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("alt:=" & pStrAltText).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntImageIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntImageIndex = 0 Then
DataImage_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntImageIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntImageIndex <> 0 Then
DataImage_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
DataImage_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("alt:=" & pStrAltText, "Index:=" & pIntImageIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Image_Exists(pStrAltText, pIntImageIndex)
dim translated_name_
translated_name_ = Local_Text(pStrAltText)
Image_Exists = DataImage_Exists(translated_name_, pIntImageIndex)
End Function

Function Verify_Image_Exists(pStrAltText, pIntImageIndex)
If Image_Exists (pStrAltText, pIntImageIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_Image_Exists", _
"image found alt = '" & pStrAltText & "', index = " & pIntImageIndex & "'"
Verify_Image_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_Image_Exists", _
"image not found alt = '" & pStrAltText & "', index = " & pIntImageIndex & "'")
Verify_Image_Exists = FAIL
End If
End Function

Function Verify_Image_NotFound(pStrAltText, pIntImageIndex)
If Image_Exists (pStrAltText, pIntImageIndex) Then
Call REPORT_FAILURE2("Verify_Image_NotFound", _
"image found alt = '" & pStrAltText & "', index = " & pIntImageIndex & "'")

Verify_Image_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_Image_NotFound", _
"image not found alt = '" & pStrAltText & "', index = " & pIntImageIndex & "'"
Verify_Image_NotFound = PASS
End If
End Function

Function Verify_DataImage_Exists(pStrAltText, pIntImageIndex)
If DataImage_Exists (pStrAltText, pIntImageIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_DataImage_Exists", _
"image found alt = '" & pStrAltText & "', index = " & pIntImageIndex & "'"
Verify_DataImage_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_DataImage_Exists", _
"image not found alt = '" & pStrAltText & "', index = " & pIntImageIndex & "'")
Verify_DataImage_Exists = FAIL
End If
End Function

Function Verify_DataImage_NotFound(pStrAltText, pIntImageIndex)
If DataImage_Exists (pStrAltText, pIntImageIndex) Then
Reporter.Filter = rfEnableAll

Call REPORT_FAILURE2("Verify_DataImage_NotFound", _
"image found alt = '" & pStrAltText & "', index = " & pIntImageIndex & "'")

Verify_DataImage_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_DataImage_NotFound", _
"image not found alt = '" & pStrAltText & "', index = " & pIntImageIndex & "'"
Verify_DataImage_NotFound = PASS
End If
End Function

Function Count_Image (pStrAltText)
dim i_
i_=0
while (Image_Exists(pStrAltText, i_))
i_=i_+1
wend
Count_Image = i_
End Function

Function Count_DataImage (pStrAltText)
dim i_
i_=0
while (DataImage_Exists(pStrAltText, i_))
i_=i_+1
wend
Count_DataImage = i_
End Function

Function Click_Image(pStrAltText, pIntImageIndex)
dim translated_name_
translated_name_ = Local_Text(pStrAltText)
If Image_Exists (pStrAltText, pIntImageIndex) Then
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("alt:="& translated_name_, "Index:=" & pIntImageIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("alt:="& translated_name_, "Index:=" & pIntImageIndex).Click
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & translated_name_ & "' clicked" , _
"Click_Image function clicked'" & translated_name_ & "' image")

Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Click_Image = PASS
Else
Call REPORT_FAILURE2("Image not found: " & translated_name_ ,". Click_Image Failed. English value was: " & pStrAltText & ". Index was: " & pIntImageIndex)
Click_Image = FAIL
End If
Reporter.Filter = rfEnableAll
End Function

'This function is used for a link that downloads a file
' e.g. "Export Table to PDF Format" link in Finder
' Windows(IE) blocks a downloading caused by event-based-click so far and in fact we use event-based-click in QTP.
Function Click_DownloadImage(pStrAltText, pIntImageIndex)
'If the setting is 1: Events, IE blocks the popup dialog.
Setting.WebPackage("ReplayType") = 2
Call Click_Image(pStrAltText, pIntImageIndex)
Setting.WebPackage("ReplayType") = 1
End Function



Function Click_DataImage(pStrAltText, pIntImageIndex)
If DataImage_Exists (pStrAltText, pIntImageIndex) Then
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("alt:=" & pStrAltText, "Index:=" & pIntImageIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("alt:=" & pStrAltText, "Index:=" & pIntImageIndex).Click
Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Click_DataImage = PASS
Else
Call REPORT_FAILURE2("Image not found: " & pStrAltText ,"Click_DataImage Failed. Index was: " & pIntImageIndex)
Click_DataImage = FAIL
End If
End Function

Function Image_Exists_byHtmlid(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
dim translated_name_
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
translated_name_ = Local_Text(pStrName)
Reporter.Filter = rfDisableAll
'check existence without index parameter.
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("html id:=" & translated_name_).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntIndex = 0 Then
Image_Exists_byHtmlid= True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntIndex <> 0 Then
Image_Exists_byHtmlid= False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
Image_Exists_byHtmlid= Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("html id:=" & translated_name_, "Index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Verify_Image_Exists_byHtmlid(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
If Image_Exists_byHtmlid(pStrName, pIntIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Image found: " & pStrName ,"."
Verify_Image_Exists_byHtmlid = PASS
Else
Call REPORT_FAILURE2("Image not found: " & pStrName, _
"Image not found: " & pStrName)
Verify_Image_Exists_byHtmlid = FAIL
End If
End Function

Function Click_Image_byHtmlid(pStrHTMLID, pIntIndex)
If Image_Exists_byHtmlid (pStrHTMLID, pIntIndex) then
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("html id:="& pStrHTMLID, "Index:=" & pIntIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("html id:="& pStrHTMLID, "Index:=" & pIntIndex).Click
Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Click_Image_byHtmlid = PASS
Call REPORT_MSG2("Click_Image_byHtmlid " & pStrHTMLID, _
"'" & pStrHTMLID & "' index='" & pIntIndex & "' image is clicked")

Else
Call REPORT_FAILURE2("Image not found: " & pStrHTMLID , _
". Click_Image_byHtmlid Failed. " & pStrHTMLID)
Click_Image_byHtmlid= FAIL
End If
End Function

Function Image_Exists_byName(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
'dim translated_name_ ' MAX: no need to translate, using HTML name here...
'translated_name_ = Local_Text(pStrName)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("name:=" & pStrName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntIndex = 0 Then
Image_Exists_byName= True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntIndex <> 0 Then
Image_Exists_byName= False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
Image_Exists_byName= Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("name:=" & pStrName, "Index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Verify_Image_Exists_byName(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
If Image_Exists_byName(pStrName, pIntIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Image found: " & pStrName ,"."
Verify_Image_Exists_byName = PASS
Else
Call REPORT_FAILURE2("Image not found: " & pStrName, _
"Image not found: " & pStrName)
Verify_Image_Exists_byName = FAIL
End If
End Function

Function Click_Image_byName(pStrName, pIntIndex)
'dim translated_name_ ' MAX: no need to translate, using HTML name here...
'translated_name_ = Local_Text(pStrName)
If Image_Exists_byName (pStrName, pIntIndex) then
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("name:="& pStrName, "Index:=" & pIntIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("name:="& pStrName, "Index:=" & pIntIndex).Click
Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend

Call REPORT_MSG("Click_Image_byName:" & pStrName & " clicked")

Check_For_Error_On_The_Page() ' check for error
Click_Image_byName = PASS
Else
Call REPORT_FAILURE2("Image not found: " & pStrName ,". Click_Image_byName Failed. Namee was: " & pStrName)
Click_Image_byName= FAIL
End If
End Function

Function Image_Exists_byImageFileName(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
'check existence without index parameter.
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("file name:=" & pStrName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntIndex = 0 Then
Image_Exists_byImageFileName= True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntIndex <> 0 Then
Image_Exists_byImageFileName= False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
Image_Exists_byImageFileName= Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("file name:=" & pStrName, "Index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Verify_Image_Exists_byImageFileName(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
If Image_Exists_byImageFileName(pStrName, pIntIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Image found: " & pStrName ,"."
Verify_Image_Exists_byImageFileName = PASS
Else
Call REPORT_FAILURE2("Image not found: " & pStrName, _
"Image not found: " & pStrName)
Verify_Image_Exists_byImageFileName = FAIL
End If
End Function

Function Click_Image_byImageFileName(pStrName, pIntIndex)
If Image_Exists_byImageFileName (pStrName, pIntIndex) then
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("file name:="& pStrName, "Index:=" & pIntIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Image("file name:="& pStrName, "Index:=" & pIntIndex).Click
Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Click_Image_byImageFileName = PASS
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & pStrName & "' clicked" , _
"Click_Image_byImageFileName function clicked'" & pStrName & "' image")
Else
Call REPORT_FAILURE2("Image not found: " & pStrName ,"Click_Image_byImageFileName Failed.")
Click_Image_byImageFileName= FAIL
End If
End Function

'---------------------------------------------------------------------------------------------
' TextField Object section
'No need to translate
'---------------------------------------------------------------------------------------------
Function TextField_Exists(pStrTextFieldName, pIntTextFieldIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrTextFieldName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntTextFieldIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntTextFieldIndex = 0 Then
TextField_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntTextFieldIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntTextFieldIndex <> 0 Then
TextField_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
TextField_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrTextFieldName, "Index:=" & pIntTextFieldIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function Verify_TextField_Exists(pStrTextFieldName, pIntTextFieldIndex)
If TextField_Exists (pStrTextFieldName, pIntTextFieldIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Text field found: " & pStrTextFieldName ,"."
Verify_TextField_Exists = PASS
Else
Call REPORT_FAILURE2("Text field not found: " & pStrTextFieldName, _
"Text field not found: " & pStrTextFieldName)
Verify_TextField_Exists = FAIL
End If
End Function

Function Verify_TextField_NotFound(pStrTextFieldName, pIntTextFieldIndex)
If TextField_Exists (pStrTextFieldName, pIntTextFieldIndex) Then

Call REPORT_FAILURE2("Text field found: " & pStrTextFieldName, _
"Text field found: " & pStrTextFieldName)
Verify_TextField_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Text field not found: " & pStrTextFieldName ,"."
Verify_TextField_NotFound = PASS
End If
End Function

' USAGE
' TextField_Enabled("domain_AllocatedBudget_timeRevenue_value", 0)
' RETURN
' read only -> False, writable-> True, does not exist -> False
Function TextField_Enabled(pStrTextFieldName, pIntTextFieldIndex)
If Not TextField_Exists(pStrTextFieldName, pIntTextFieldIndex) Then
Call REPORT_FAILURE2("TextField_Enabled:'" & pStrTextFieldName & "' text field not found", _
"TextField_Enabled:'" & pStrTextFieldName & "' text field not found")
TextField_Enabled = False
Exit Function
End If

Reporter.Filter = rfDisableAll
' Check 'readonly' property. 1: read only(disable), 0: enable.
If Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrTextFieldName, "Index:=" & pIntTextFieldIndex).GetROProperty("readonly") = 1 Then
TextField_Enabled = False
Else
TextField_Enabled = True
End If

End Function

Function Verify_TextField_Enabled(pStrTextFieldName, pIntTextFieldIndex)
If TextField_Enabled(pStrTextFieldName, pIntTextFieldIndex) Then
Call REPORT_PASS("Verify_TextField_Enabled:'" & pStrTextFieldName & "' Enabled", _
"Verify_TextField_Enabled:'" & pStrTextFieldName & "' Enabled")
Verify_TextField_Enabled = PASS
Else
Call REPORT_FAILURE2("Verify_TextField_Enabled:'" & pStrTextFieldName & "' Disabled", _
"Verify_TextField_Enabled:'" & pStrTextFieldName & "' Disabled")
Verify_TextField_Enabled = FAIL
End If
End Function

Function Verify_TextField_Disabled(pStrTextFieldName, pIntTextFieldIndex)
If TextField_Enabled(pStrTextFieldName, pIntTextFieldIndex) Then
Call REPORT_FAILURE2("Verify_TextField_Disabled:'" & pStrTextFieldName & "' Enabled", _
"Verify_TextField_Disabled:'" & pStrTextFieldName & "' Enabled")
Verify_TextField_Disabled = FAIL
Else
Call REPORT_PASS("Verify_TextField_Disabled:'" & pStrTextFieldName & "' Disabled", _
"Verify_TextField_Disabled:'" & pStrTextFieldName & "' Disabled")
Verify_TextField_Disabled = PASS
End If
End Function



Function Count_TextField (pStrTextFieldName)
dim i_
i_=0
while (TextField_Exists(pStrTextFieldName, i_))
i_=i_+1
wend
Count_TextField = i_
End Function

Function Get_TextField(pStrTextFieldName, pIntTextFieldIndex)
If TextField_Exists(pStrTextFieldName, pIntTextFieldIndex) Then
Reporter.Filter = rfDisableAll
Get_TextField = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrTextFieldName, "Index:=" & pIntTextFieldIndex).GetROProperty("value")
Else
Call REPORT_FAILURE2("Get_TextField: could not get any value", _
"Get_TextField: could not get any value from object name '" & pStrTextFieldName & "' and index= '" & pIntTextFieldIndex & "'")
End If
End Function

Function Verify_TextField_Value(pStrTextFieldName, pIntTextFieldIndex,pStrValue)
Dim actualValue
'translated_name_ = Local_Text(pStrValue)
actualValue=Trim(Get_TextField(pStrTextFieldName, pIntTextFieldIndex))
'If actualValue=translated_name_ Then
If actualValue=Trim(pStrValue) Then
Call REPORT_PASS("Verify_TextField_Value('" & pStrTextFieldName & "')", "TextField Value found: Value = '" & pStrValue & "', is shown'")
Verify_TextField_Value = PASS
Else
Call REPORT_FAILURE2("Verify_TextField_Value('" & pStrTextFieldName & "')", "TextField Value shown is '" & actualValue & "', NOT '" & pStrValue & "'.")
Verify_TextField_Value = FAIL
End If
End Function

Function Set_TextField (pStrTextFieldName, pIntTextFieldIndex, pStrValue)
If (TextField_Exists (pStrTextFieldName, pIntTextFieldIndex)) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrTextFieldName, "Index:=" & pIntTextFieldIndex).MouseOver
If IsNull(pStrValue) Then
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrTextFieldName, "Index:=" & pIntTextFieldIndex).Set ("")
Else
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrTextFieldName, "Index:=" & pIntTextFieldIndex).Set (pStrValue)
End If
Call REPORT_MSG2("Set_TextField function set'" & pStrValue & "' in '" & pStrTextFieldName & "' field", "Set_TextField function set'" & pStrValue & "' in '" & pStrTextFieldName & "' field")
Sync_Page
Set_TextField = PASS
Else
Call REPORT_FAILURE2("Text Field not found: " & pStrTextFieldName ,". Set_TextField Failed.")
Set_TextField = FAIL
End If
End Function

function TextField_Exists_ByHtmlID (pStrTexthtmlId,pIntTextFieldIndex)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
TextField_Exists_ByHtmlID = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("html id:=" & pStrTexthtmlId,"Index:=" & pIntTextFieldIndex).Exist(OBJECT_EXIST_TIME_OUT)
end function

Function Set_TextFieldByHtmlID (pStrTexthtmlId, pIntTextFieldIndex, pStrValue)
If (TextField_Exists_ByHtmlID (pStrTexthtmlId, pIntTextFieldIndex)) Then
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("html id:=" & pStrTexthtmlId, "Index:=" & pIntTextFieldIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("html id:=" & pStrTexthtmlId, "Index:=" & pIntTextFieldIndex).Set (pStrValue)
Sync_Page
Set_TextFieldByHtmlID = PASS
Else
Call REPORT_FAILURE2("Text Field html id not found: " & pStrTexthtmlId ,". Set_TextField Failed.")
Set_TextFieldByHtmlID = FAIL
End If
End Function

Function Get_TextField_ByHtmlID(pStrTextFieldName, pIntTextFieldIndex)
If TextField_Exists_ByHtmlID(pStrTextFieldName, pIntTextFieldIndex) Then
Reporter.Filter = rfDisableAll
Get_TextField_ByHtmlID = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("html id:=" & pStrTextFieldName, "Index:=" & pIntTextFieldIndex).GetROProperty("value")
Else
Call REPORT_FAILURE2("Get_TextField_ByHtmlID: could not get any value" , _
"Get_TextField_ByHtmlID: could not get any value from object name '" & pStrTextFieldName & "' and index= '" & pIntTextFieldIndex & "'")
Get_TextField_ByHtmlID = FAIL
End If
End Function

Function Verify_TextField_Value_ByHtmlID(pStrTextFieldName, pIntTextFieldIndex, pStrValue)
Dim actualValue
'translated_name_ = Local_Text(pStrValue)
actualValue=Trim(Get_TextField_ByHtmlID(pStrTextFieldName, pIntTextFieldIndex))
'If actualValue=translated_name_ Then
If actualValue=Trim(pStrValue) Then
Call REPORT_PASS("Verify_TextField_Value_ByHtmlID('" & pStrTextFieldName & "')", "TextField Value found: Value = '" & pStrValue & "', is shown'")
Verify_TextField_Value_ByHtmlID = PASS
Else
Call REPORT_FAILURE2("Verify_TextField_Value_ByHtmlID('" & pStrTextFieldName & "')", "TextField Value shown is '" & actualValue & "', NOT '" & pStrValue & "'.")
Verify_TextField_Value_ByHtmlID = FAIL
End If
End Function







function TextField_Exists_ByIndex (pIntTextFieldIndex)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
TextField_Exists_ByIndex = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Index:=" & pIntTextFieldIndex).Exist(OBJECT_EXIST_TIME_OUT)
end function

Function Set_TextField_ByIndex (pIntTextFieldIndex, pStrValue)
If Not TextField_Exists_ByIndex(pIntTextFieldIndex) Then
Call REPORT_FAILURE2("Text Field not found, Index was: " & pIntTextFieldIndex ,". Set_TextField_ByIndex Failed.")
Call CaptureWindowImage("Text Field not found: index = " & pIntTextFieldIndex)
Set_TextField_ByIndex = FAIL
Exit Function
End If

Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Index:=" & pIntTextFieldIndex).Set (pStrValue)
Sync_Page
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"Set_TextField_ByIndex set '" & pStrValue & "' at index '" & pIntTextFieldIndex & "'", _
"Set_TextField_ByIndex set '" & pStrValue & "' at index '" & pIntTextFieldIndex & "' field name is '" & Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Index:=" & pIntTextFieldIndex).GetROProperty("name") & "'")
Set_TextField_ByIndex = PASS

End Function

'This function is for Secure TextField like Password field.
Function SetSecure_TextField (pStrTextFieldName, pIntTextFieldIndex, pStrValue)
If (TextField_Exists (pStrTextFieldName, pIntTextFieldIndex)) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrTextFieldName, "Index:=" & pIntTextFieldIndex).SetSecure (pStrValue)
Sync_Page
SetSecure_TextField = PASS
Else
Call REPORT_FAILURE2("Text Field not found: " & pStrTextFieldName ,"SetSecure_TextField Failed.")
SetSecure_TextField = FAIL
End If
End Function

Function NumberField_Exists(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
dim translated_name_
translated_name_ = Local_Number(pStrName)
Reporter.Filter = rfDisableAll
NumberField_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & translated_name_, "Index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function DateField_Exists(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
dim translated_name_
translated_name_ = Local_Date(pStrName)
Reporter.Filter = rfDisableAll
DateField_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & translated_name_, "Index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function Verify_NumberField_Exists(pStrContext, pIntContextIndex) ' open issue: pIntContextIndex IS required...
If NumberField_Exists (pStrContext, pIntContextIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Number field found: " & pStrContext ,"."
Verify_NumberField_Exists = PASS
Else
Call REPORT_FAILURE2("Number field not found: " & pStrContext, _
"Number field not found: " & pStrContext)
Verify_NumberField_Exists = FAIL
End If
End Function

Function Verify_DateField_Exists(pStrContext, pIntContextIndex) ' open issue: pIntContextIndex IS required...
If DateField_Exists (pStrContext, pIntContextIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Date field found: " & pStrContext ,"."
Verify_DateField_Exists = PASS
Else
Call REPORT_FAILURE2("Date field not found: " & pStrContext, _
"Date field not found: " & pStrContext)
Verify_DateField_Exists = FAIL
End If
End Function

Function Set_NumberField (pStrName, pIntIndex, pStrValue) '---> number will be translated inside of the function ' open issue: pIntIndex IS required...
If (NumberField_Exists (pStrName, pIntIndex)) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrName, "Index:=" & pIntIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrName, "Index:=" & pIntIndex).Set (pStrValue)
Sync_Page
Set_NumberField = PASS
Else
Call REPORT_FAILURE2("Number Field not found: " & pStrName ,". Set_NumberField Failed.")
Set_NumberField = FAIL
End If
End Function

Function Set_DateField (pStrName, pIntIndex, pStrValue) '---> date will be translated inside of the function ' open issue: pIntIndex IS required...
If (DateField_Exists (pStrName, pIntIndex)) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrName, "Index:=" & pIntIndex).MouseOver
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebEdit("Name:=" & pStrName, "Index:=" & pIntIndex).Set (pStrValue)
Sync_Page
Set_DateField = PASS
Else
Call REPORT_FAILURE2("Date Field not found: " & pStrName ,"Set_DateField Failed.")
Set_DateField = FAIL
End If
End Function

Function Verify_TextFieldDataValue(pStrTextFieldName, pIntTextFieldIndex, pStrValue)
Dim actualValue
actualValue=Get_TextField(pStrTextFieldName, pIntTextFieldIndex)
If actualValue=pStrValue Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_TextFieldDataValue", _
"TextFieldValue found: Name = '" & pStrValue & "', is selected'"
Verify_TextFieldDataValue = PASS
Else
Call REPORT_FAILURE2("Verify_TextFieldDataValue", "TextFieldValue selected is '" & actualValue & "', NOT '" & pStrValue & "'.")
Verify_TextFieldDataValue = FAIL
End If
End Function

Function Verify_TextFieldValue(pStrTextFieldName, pIntTextFieldIndex, pStrValue)
Dim translated_name_
Dim actualValue
translated_name_ = Local_Text(pStrValue)
actualValue=Get_TextField(pStrTextFieldName, pIntTextFieldIndex)
If actualValue=translated_name_ Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_TextFieldValue", _
"TextFieldValue found: Name = '" & translated_name_ & "', is selected'"
Verify_TextFieldValue = PASS
Else
Call REPORT_FAILURE2("Verify_TextFieldValue", _
"TextFieldValue selected is '" & actualValue & "', NOT '" & translated_name_ & "'.")
Verify_TextFieldValue = FAIL
End If
End Function

Function Get_DateField()
End Function

Function Get_NumberField()
End Function

'---------------------------------------------------------------------------------------------
' List Object Section
'---------------------------------------------------------------------------------------------
Function FileField_Exists(pStrFileFieldName, pIntFileFieldIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebFile("Name:=" & pStrFileFieldName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntFileFieldIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntFileFieldIndex = 0 Then
FileField_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntFileFieldIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntFileFieldIndex <> 0 Then
FileField_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
FileField_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebFile("Name:=" & pStrFileFieldName, "Index:=" & pIntFileFieldIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function Set_FileField (pStrFileFieldName, pIntFileFieldIndex, pStrValue)
If (FileField_Exists (pStrFileFieldName, pIntFileFieldIndex)) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebFile("Name:=" & pStrFileFieldName, "Index:=" & pIntFileFieldIndex).Set (pStrValue)
Sync_Page
Call REPORT_MSG2("File name '" & pStrValue & "' set", _
"Set_FileField set file '" & pStrValue & "' in '" & pStrFileFieldName & "' index(" & pIntComboboxIndex & ")")
Set_FileField = PASS
Else
Call REPORT_FAILURE2("File Field not found: " & pStrFileFieldName ,". Set_FileField Failed.")
Set_FileField = FAIL
End If
End Function

'---------------------------------------------------------------------------------------------
' RadioGroup/RadioButton Object section
'---------------------------------------------------------------------------------------------
' No need to translate
Function RadioGroup_Exists(pStrGroupName)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
RadioGroup_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).Exist(OBJECT_EXIST_TIME_OUT)
End Function

' No need to translate
Function RadioButton_Exists_ByValue(pStrGroupName, pStrItemValue)
If Not RadioGroup_Exists(pStrGroupName) Then
RadioButton_Exists_ByValue = False
Exit Function
End If
'see "all items" property and seek for value keyword.
Dim all_items
Reporter.Filter = rfDisableAll
all_items = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).GetROProperty("all items")
If Instr(1, all_items, pStrItemValue, vbTextCompare) = 0 Then
RadioButton_Exists_ByValue = False
Else
RadioButton_Exists_ByValue = True
End If
End Function

' No need to translate
Function RadioButton_Exists_ByIndex(pStrGroupName, pIntItemIndex)
If Not RadioGroup_Exists(pStrGroupName) Then
RadioButton_Exists_ByIndex = False
Exit Function
End If
Reporter.Filter = rfDisableAll
If pIntItemIndex < Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).GetROProperty("items count") Then
RadioButton_Exists_ByIndex = True
Else
RadioButton_Exists_ByIndex = False
End If
End Function

' No need to translate
Function Verify_RadioGroup_Exists(pStrGroupName)
If RadioGroup_Exists(pStrGroupName) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Verify_RadioGroup_Exists","Radio Group found: " & pStrGroupName
Verify_RadioGroup_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_RadioGroup_Exists", "Radio Group not found: " & pStrGroupName)
Verify_RadioGroup_Exists = FAIL
End If
End Function

' No need to translate
Function Verify_RadioGroup_NotFound(pStrGroupName)
If RadioGroup_Exists(pStrGroupName) Then
Call REPORT_FAILURE2("Verify_RadioGroup_NotFound","Radio Group found: " & pStrGroupName)
Verify_RadioGroup_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Verify_RadioGroup_NotFound", "Radio Group not found: " & pStrGroupName
Verify_RadioGroup_NotFound = PASS
End If
End Function

Function Verify_RadioButton_Exists_ByValue(pStrGroupName, pStrItemValue)
If RadioButton_Exists_ByValue (pStrGroupName, pStrItemValue) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass ,"Verify_RadioButton_Exists_ByValue", "Radio button found: RadioGroup='" & pStrGroupName & "' RadioButton='" & pStrItemValue & "'"
Verify_RadioButton_Exists_ByValue = PASS
Else
Call REPORT_FAILURE2("Verify_RadioButton_Exists_ByValue", _
"Radio button not found: RadioGroup='" & pStrGroupName & "' RadioButton='" & pStrItemValue & "'")
Verify_RadioButton_Exists_ByValue = FAIL
End If
End Function

Function Verify_RadioButton_NotFound_ByValue(pStrGroupName, pStrItemValue)
If RadioButton_Exists_ByValue (pStrGroupName, pStrItemValue) Then
Call REPORT_FAILURE2("Verify_RadioButton_NotFound_ByValue", _
"Radio button found: RadioGroup='" & pStrGroupName & "' RadioButton='" & pStrItemValue & "'")
Verify_RadioButton_NotFound_ByValue = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass ,"Verify_RadioButton_NotFound_ByValue", "Radio button not found: RadioGroup='" & pStrGroupName & "' RadioButton='" & pStrItemValue & "'"
Verify_RadioButton_NotFound_ByValue = PASS
End If
End Function

Function Count_RadioButton (pStrGroupName)
If Not RadioGroup_Exists(pStrGroupName) Then
Count_RadioButton = 0
Exit Function
End if
Reporter.Filter = rfDisableAll
Count_RadioButton = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).GetROProperty("items count")
End Function

'DELETE_ME ***********************************
' RadioGroup does not care Index so index parameter is not necessary.
'Function Set_RadioButton (pStrName, pIntIndex, pStrValue) '---> translation! ' open issue: pIntIndex IS required...
' If (RadioButton_Exists_ByValue (pStrName, pIntIndex)) Then
' Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrName, "Index:=" & pIntIndex).MouseOver
' Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrName, "Index:=" & pIntIndex).Select (pStrValue)
' Set_RadioButton = PASS
' Else
' Reporter.ReportEvent micFail, "Radio button not found: " & pStrName ,". Set_RadioButton Failed."
' Set_RadioButton = FAIL
' End If
'End Function
'DELETE_ME ***********************************

Function Set_RadioButtonOn_ByValue(pStrGroupName, pStrItemValue)
' two cases: SSL and non-SSL, have to handle them differently
if LCase(HTTP_VALUE) = LCase("http://") then
' non-SSL
If (RadioButton_Exists_ByValue (pStrGroupName, pStrItemValue)) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).Select (pStrItemValue)
Sync_Page
Set_RadioButtonOn_ByValue = PASS
Else
Call REPORT_FAILURE2("Set_RadioButtonOn_ByValue", _
"Radio button has not found: RadioGroup='" & pStrGroupName & "', button value = '" & pStrItemValue & "'")
Set_RadioButtonOn_ByValue = FAIL
End If
Else
' SSL case:
REPORT_WARNING("Set_RadioButtonOn_ByValue function is not working properly under SSL: it skips verification")
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName, "Index:=0").Select (pStrItemValue)
Sync_Page
Set_RadioButtonOn_ByValue = PASS

End if
End Function

Function Set_RadioButtonOn_ByIndex(pStrGroupName, pIntItemIndex)
If RadioButton_Exists_ByIndex(pStrGroupName, pIntItemIndex) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).Select ("#" & pIntItemIndex)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & pStrGroupName & "', '" & pIntItemIndex & "' radio button selected" , _
"Set_RadioButtonOn_ByIndex function selected '" & pStrGroupName & "', index = '" & pIntItemIndex & "' radio button")
Sync_Page
Set_RadioButtonOn_ByIndex = PASS
Else
Call REPORT_FAILURE2("Set_RadioButtonOn_ByIndex", _
"Radio button has not found: RadioGroup='" & pStrGroupName & "', button index = '" & pIntItemIndex & "'")
Set_RadioButtonOn_ByIndex = FAIL
End If
End Function

'RETURN
' index:
' "": if the specified radio group does not exist or if any raido button has not checked yet.
Function Get_SelectedRadioButtonIndex(pStrGroupName)
If Not RadioGroup_Exists(pStrGroupName) Then
Get_SelectedRadioButtonIndex = ""
Exit Function
End If
Reporter.Filter = rfDisableAll
If Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).GetROProperty("checked") = 0 Then
Call REPORT_FAILURE2("Get_SelectedRadioButtonIndex", _
"Radio button has not checked: RadioGroup='" & pStrGroupName & "'")
Get_SelectedRadioButtonIndex = ""
Exit Function
End If
Reporter.Filter = rfDisableAll
Get_SelectedRadioButtonIndex = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).GetROProperty("selected item index") - 1
End Function

'RETURN:
' string value: if the specified radio group is already selected a button
' null: if the specified radio group has not selected a button yet.
' or there is not the group.
Function Get_SelectedRadioButtonValue(pStrGroupName)
If RadioGroup_Exists(pStrGroupName) Then
Reporter.Filter = rfDisableAll
If Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).GetROProperty("checked") = 0 Then
Get_SelectedRadioButtonValue = null
Else
Reporter.Filter = rfDisableAll
Get_SelectedRadioButtonValue = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebRadioGroup("Name:=" & pStrGroupName).GetROProperty("value")
End IF
Else
Call REPORT_FAILURE2("Get_SelectedRadioButtonValue: could not find object", _
"Get_SelectedRadioButtonValue: could not find object name '" & pStrGroupName & "'")
Get_SelectedRadioButtonValue = null
End if
End Function

'---------------------------------------------------------------------------------------------
' CheckBox Object Section
'---------------------------------------------------------------------------------------------
'CheckBox has 3 attributes that are Group Name, Value, Index
'Here is 3 senarios between Group Name and Index
' 1 checkbox in a checkbox group.
' WebCheckBox("Name:=xxx").Exist method returns True
' WebCheckBox("Name:=xxx", "Index:=xxx").Exist method returns always True regardless of Index.
' more than 2 checkboxes in a checkbox group.
' WebCheckBox("Name:=xxx").Exist method returns False
' WebCheckBox("Name:=xxx", "Index:=xxx").Exist method returns properly depending on Index.
' Not the specified checkbox group in a page
' WebCheckBox("Name:=xxx").Exist method returns False
' WebCheckBox("Name:=xxx", "Index:=0").Exist method returns False
Function CheckBox_Exists_ByIndex(pStrGroupName, pIntItemIndex)
Call Initiate_wHandle ' make sure hWindow is known
Dim existenceWithoutIndex_, existenceWithIndex_
If pIntItemIndex="" or IsNull(pIntItemIndex) Then
pIntItemIndex = 0
End If
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Name:=" & pStrGroupName).Exist(OBJECT_EXIST_TIME_OUT)
existenceWithIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Name:=" & pStrGroupName, "Index:=" & pIntItemIndex).Exist(OBJECT_EXIST_TIME_OUT)
IF existenceWithoutIndex_ and pIntItemIndex = 0 Then
CheckBox_Exists_ByIndex = True
Reporter.Filter = rfEnableAll
Exit Function
End If
IF existenceWithoutIndex_ and pIntItemIndex <> 0 Then
CheckBox_Exists_ByIndex = False
Reporter.Filter = rfEnableAll
Exit Function
End If
CheckBox_Exists_ByIndex = existenceWithIndex_
Reporter.Filter = rfEnableAll
End Function

Function CheckBox_Exists_ByIndex_Only (pIntItemIndex)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
CheckBox_Exists_ByIndex_Only = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Index:=" & pIntItemIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
end function

Function CheckBox_Exists_ByValue(pStrGroupName, pStrValue)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
CheckBox_Exists_ByValue = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Name:=" & pStrGroupName, "Value:=" & pStrValue).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function Verify_CheckBox_Exists_ByIndex(pStrGroupName, pIntItemIndex)
If CheckBox_Exists_ByIndex(pStrGroupName, pIntItemIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_CheckBox_Exists_ByIndex", _
"Checkbox Found: checkbox group Name='" & pStrGroupName & "' checkbox Index='" & pIntItemIndex & "'"
Verify_CheckBox_Exists_ByIndex = PASS
Else
Call REPORT_FAILURE2("Verify_CheckBox_Exists_ByIndex", _
"Checkbox Not Found: checkbox group Name='" & pStrGroupName & "' checkbox Index='" & pIntItemIndex & "'")
Verify_CheckBox_Exists_ByIndex = FAIL
End If
End Function

Function Verify_CheckBox_NotFound_ByIndex(pStrGroupName, pIntItemIndex)
If CheckBox_Exists_ByIndex(pStrGroupName, pIntItemIndex) Then
Call REPORT_FAILURE2("Verify_CheckBox_NotFound_ByIndex", _
"Checkbox Found: checkbox group Name='" & pStrGroupName & "' checkbox Index='" & pIntItemIndex & "'")
Verify_CheckBox_NotFound_ByIndex = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_CheckBox_NotFound_ByIndex", _
"Checkbox Not Found: checkbox group Name='" & pStrGroupName & "' checkbox Index='" & pIntItemIndex & "'"
Verify_CheckBox_NotFound_ByIndex = PASS
End If
End Function

Function Count_CheckBox (pStrGroupName)
dim i_
i_=0
while (CheckBox_Exists_ByIndex(pStrGroupName, i_))
i_=i_+1
wend
Count_CheckBox = i_
End Function

'RETURNS
' WEB_OBJECT_ON: if it is checked.
' WEB_OBJECT_OFF: if it is NOT checked.
' Null: could not found
Function Get_CheckBoxOnOff_ByIndex(pStrGroupName, pIntItemIndex)
If CheckBox_Exists_ByIndex(pStrGroupName, pIntItemIndex) Then
Reporter.Filter = rfDisableAll
Get_CheckBoxOnOff_ByIndex = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Name:=" & pStrGroupName, "Index:=" & pIntItemIndex).GetROProperty("checked")
Else
Call REPORT_FAILURE2("Get_CheckBoxOnOff_ByIndex", _
"Checkbox Not Found: checkbox group Name='" & pStrGroupName & "' checkbox Index='" & pIntItemIndex & "'")
Get_CheckBoxOnOff_ByIndex = Null
End If

End Function

Function Set_CheckBoxOnOff_ByIndex (pStrGroupName, pIntItemIndex, pStrOnOrOff)
Reporter.Filter = rfDisableAll
If (CheckBox_Exists_ByIndex (pStrGroupName, pIntItemIndex)) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Name:=" & pStrGroupName, "Index:=" & pIntItemIndex).Set (pStrOnOrOff)
sync_page
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & pStrGroupName & "' checkbox " & pStrOnOrOff , _
"Set_CheckBoxOnOff_ByIndex made '" & pIntItemIndex & "' in '" & pStrGroupName & "' check box" & pStrOnOrOff)
Set_CheckBoxOnOff_ByIndex = PASS
Else
Call REPORT_FAILURE2("Set_CheckBoxOnOff_ByIndex can't find '" & pStrGroupName & "' index = '" & pIntItemIndex & "'", _
"Set_CheckBoxOnOff_ByIndex can't find '" & pStrGroupName & "' index = '" & pIntItemIndex & "'")
Set_CheckBoxOnOff_ByIndex = FAIL
End If
End Function

Function Set_CheckBox_ByIndex (pIntItemIndex, pStrOnOrOff)
If (CheckBox_Exists_ByIndex_Only (pIntItemIndex)) Then
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Index:=" & pIntItemIndex).Set (pStrOnOrOff)
sync_page
Set_CheckBox_ByIndex = PASS
Else
Call REPORT_FAILURE2("Check box not found: " & pStrGroupName ,". Set_CheckBox_ByIndex Failed.")
Set_CheckBox_ByIndex = FAIL
End If
End Function

Function CheckBox_Disabled(pStrCheckboxName, pIntItemIndex) ' this one and 3 below are added by Angel :)
Dim checkboxExist
Dim disabledValue
If CheckBox_Exists_ByIndex(pStrCheckboxName, pIntItemIndex) Then
Reporter.Filter = rfDisableAll
disabledValue = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Name:=" & pStrCheckboxName, "Index:=" & pIntItemIndex).GetROProperty("disabled")
If disabledValue Then
CheckBox_Disabled = PASS
Else
CheckBox_Disabled = FAIL
End If
Else
Call REPORT_FAILURE2("CheckBox_Disabled", _
"Checkbox Name='" & pStrCheckboxName & "' is not shown on the page!!!")
CheckBox_Disabled = FAIL
End If
End Function

Function CheckBox_Enabled(pStrCheckboxName, pIntItemIndex)
Dim checkboxExist
Dim disabledValue
If CheckBox_Exists_ByIndex(pStrCheckboxName, pIntItemIndex) Then
Reporter.Filter = rfDisableAll
disabledValue = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Name:=" & pStrCheckboxName, "Index:=" & pIntItemIndex).GetROProperty("disabled")
If disabledValue=0 Then
CheckBox_Enabled = PASS
Else
CheckBox_Enabled = FAIL
End If
Else
Call REPORT_FAILURE2("CheckBox_Enabled", _
"Checkbox Name='" & pStrCheckboxName & "' is not shown on the page!!!")
CheckBox_Enabled = FAIL
End If
End Function

Function Verify_CheckBox_Disabled(pStrCheckboxName, pIntItemIndex)
if CheckBox_Disabled(pStrCheckboxName, pIntItemIndex) = PASS Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_CheckBox_Disabled", _
"Checkbox Name='" & pStrCheckboxName & "' is in fact disabled"
Verify_CheckBox_Disabled = PASS
else
Call REPORT_FAILURE2("Verify_CheckBox_Disabled", _
"Checkbox Name='" & pStrCheckboxName & "' is NOT disabled. Instead, it is ENABLED (or not present, see above)")
Verify_CheckBox_Disabled = FAIL
end if
End Function

Function Verify_CheckBox_Enabled(pStrCheckboxName, pIntItemIndex)
if CheckBox_Enabled(pStrCheckboxName, pIntItemIndex) = PASS Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_CheckBox_Enabled", _
"Checkbox Name='" & pStrCheckboxName & "' is in fact enabled"
Verify_CheckBox_Enabled = PASS
else
Call REPORT_FAILURE2("Verify_CheckBox_Enabled", _
"Checkbox Name='" & pStrCheckboxName & "' is NOT enabled. Instead, it is DISABLED (or not present, see above)")
Verify_CheckBox_Enabled = FAIL
end if
End Function


'Description
' Return true when the specified checkbox is checked.
' Return false when the specified checkbox is NOT checked.
'Usage
' Msgbox Is_CheckBox_Checked("UI:SELECT:SELECTION:0", 0)
Function Is_CheckBox_Checked(pStrGroupName, pIntItemIndex)
If Not (CheckBox_Exists_ByIndex (pStrGroupName, pIntItemIndex)) Then
Call REPORT_FAILURE2("Check box not found: " & pStrGroupName ,". Is_CheckBox_Checked Failed.")
Is_CheckBox_Checked = false
End If

Reporter.Filter = rfDisableAll
If Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebCheckBox("Name:=" & pStrGroupName, "Index:=" & pIntItemIndex).GetROProperty("checked") = 1 Then
Is_CheckBox_Checked = True
Else
Is_CheckBox_Checked = false
End If

End Function

Function Verify_CheckBox_Checked(pStrGroupName, pIntItemIndex)
If Is_CheckBox_Checked(pStrGroupName, pIntItemIndex) Then
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent (micPass , _
"The checkbox '" & pStrGroupName & "' index = '" & pIntItemIndex & "' is checked", _
"Verify_CheckBox_Checked: The checkbox '" & pStrGroupName & "' index = '" & pIntItemIndex & "' is checked")
Verify_CheckBox_Checked = PASS
Else
Call REPORT_FAILURE2("The checkbox '" & pStrGroupName & "' index = '" & pIntItemIndex & "' is not checked", _
"Verify_CheckBox_Checked: The checkbox '" & pStrGroupName & "' index = '" & pIntItemIndex & "' is not checked")
Verify_CheckBox_Checked = FAIL
End If
End Function

Function Verify_CheckBox_Unchecked(pStrGroupName, pIntItemIndex)
If Is_CheckBox_Checked(pStrGroupName, pIntItemIndex) Then
Call REPORT_FAILURE2("The checkbox '" & pStrGroupName & "' index = '" & pIntItemIndex & "' is checked", _
"Verify_CheckBox_Unchecked: The checkbox '" & pStrGroupName & "' index = '" & pIntItemIndex & "' is checked")
Verify_CheckBox_Unchecked = FAIL
Else
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(misPass, _
"The checkbox '" & pStrGroupName & "' index = '" & pIntItemIndex & "' is not checked", _
"Verify_CheckBox_Unchecked: The checkbox '" & pStrGroupName & "' index = '" & pIntItemIndex & "' is not checked")
Verify_CheckBox_Unchecked = PASS
End If
End Function


'---------------------------------------------------------------------------------------------
' ComboBox Object Section
'---------------------------------------------------------------------------------------------
' Don't need to translate!
Function ComboBox_Exists(pStrComboboxName, pIntComboboxIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboboxName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntComboboxIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntComboboxIndex = 0 Then
ComboBox_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntComboboxIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntComboboxIndex <> 0 Then
ComboBox_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
ComboBox_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboboxName, "Index:=" & pIntComboboxIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function ComboBoxItem_Exists_ByIndex(pStrComboboxName, pIntComboboxIndex, pIntItemIndex)
If Not ComboBox_Exists(pStrComboboxName, pIntComboboxIndex) Then
ComboBoxItem_Exists_ByIndex = False
Exit Function
End If
Reporter.Filter = rfDisableAll
If pIntItemIndex < Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboboxName, "Index:=" & pIntComboboxIndex).GetROProperty("items count") Then
ComboBoxItem_Exists_ByIndex = True
Else
ComboBoxItem_Exists_ByIndex = False
End If
End Function

Function Verify_ComboBox_Exists(pStrComboboxName, pIntComboboxIndex)
If ComboBox_Exists (pStrComboboxName, pIntComboboxIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Combo box found: " & pStrComboboxName ,"."
Verify_ComboBox_Exists = PASS
Else
Call REPORT_FAILURE2("Combo box not found: " & pStrComboboxName, _
"Combo box not found: " & pStrComboboxName)
Verify_ComboBox_Exists = FAIL
End If
End Function

Function Verify_ComboBox_NotFound(pStrComboboxName, pIntComboboxIndex)
If ComboBox_Exists (pStrComboboxName, pIntComboboxIndex) Then
Call REPORT_FAILURE2("Combo box found: " & pStrComboboxName, _
"Combo box found: " & pStrComboboxName)
Verify_ComboBox_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Combo box not found: " & pStrComboboxName ,"."
Verify_ComboBox_NotFound = PASS
End If
End Function

Function Verify_ComboBoxItem_Exists_ByIndex(pStrComboboxName, pIntComboboxIndex, pIntItemIndex)
If ComboBoxItem_Exists_ByIndex (pStrComboboxName, pIntComboboxIndex, pIntItemIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ComboBoxItem_Exists_ByIndex", _
"ComboBox Item Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox item Index='" & pIntItemIndex & "'"
Verify_ComboBoxItem_Exists_ByIndex = PASS
Else
Call REPORT_FAILURE2("Verify_ComboBoxItem_Exists_ByIndex", _
"ComboBox Item not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox item Index='" & pIntItemIndex & "'")
Verify_ComboBoxItem_Exists_ByIndex = FAIL
End If
End Function

Function Verify_ComboBoxItem_NotFound_ByIndex(pStrComboboxName, pIntComboboxIndex, pIntItemIndex)
If ComboBoxItem_Exists_ByIndex (pStrComboboxName, pIntComboboxIndex, pIntItemIndex) Then
Call REPORT_FAILURE2("Verify_ComboBoxItem_NotFound_ByIndex", _
"ComboBox Item Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox item Index='" & pIntItemIndex & "'")
Verify_ComboBoxItem_NotFound_ByIndex = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ComboBoxItem_NotFound_ByIndex", _
"ComboBox Item not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox item Index='" & pIntItemIndex & "'"
Verify_ComboBoxItem_NotFound_ByIndex = PASS
End If
End Function

'No need to translate
Function ComboBoxItem_Exists_ByDataName(pStrComboboxName, pIntComboboxIndex, pStrItemName)
Reporter.Filter = rfDisableAll
If Not ComboBox_Exists(pStrComboboxName, pIntComboboxIndex) Then
ComboBoxItem_Exists_ByDataName = False
Exit Function
End If
Dim all_items
Reporter.Filter = rfDisableAll
all_items = SeparateToken(Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboboxName, "Index:=" & pIntComboboxIndex).GetROProperty("all items"), ";")

Dim aitem
ComboBoxItem_Exists_ByDataName = False
For Each aitem In all_items
If aitem = pStrItemName Then
ComboBoxItem_Exists_ByDataName = True
Exit For
End If
Next
Reporter.Filter = rfEnableAll
End Function

Function ComboBoxItem_Exists_ByName(pStrComboboxName, pIntComboboxIndex, pStrItemName)
dim translated_name_
translated_name_ = Local_Text(pStrItemName)
ComboBoxItem_Exists_ByName = ComboBoxItem_Exists_ByDataName(pStrComboboxName, pIntComboboxIndex, translated_name_)
End Function

Function ComboBox_Exists_ByIndex (pIntComboboxIndex)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
ComboBox_Exists_ByIndex= Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Index:=" & pIntComboboxIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function Verify_ComboBoxItem_Exists_ByDataName(pStrComboboxName, pIntComboboxIndex, pStrItemName)
If ComboBoxItem_Exists_ByDataName(pStrComboboxName, pIntComboboxIndex, pStrItemName) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ComboBoxItem_Exists_ByDataName", _
"ComboBox Item Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox Name='" & pStrItemName & "'"
Verify_ComboBoxItem_Exists_ByDataName = PASS
Else
Call REPORT_FAILURE2("Verify_ComboBoxItem_Exists_ByDataName", _
"ComboBox Item Not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox Name='" & pStrItemName & "'")
Verify_ComboBoxItem_Exists_ByDataName = FAIL
End If
End Function

Function Verify_ComboBoxItem_NotFound_ByDataName(pStrComboboxName, pIntComboboxIndex, pStrItemName)
If ComboBoxItem_Exists_ByDataName(pStrComboboxName, pIntComboboxIndex, pStrItemName) Then
Call REPORT_FAILURE2("Verify_ComboBoxItem_NotFound_ByDataName", _
"ComboBox Item Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox Name='" & pStrItemName & "'")
Verify_ComboBoxItem_NotFound_ByDataName = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ComboBoxItem_NotFound_ByDataName", _
"ComboBox Item Not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox Name='" & pStrItemName & "'"
Verify_ComboBoxItem_NotFound_ByDataName = PASS
End If
End Function

Function Verify_ComboBoxItem_Exists_ByName(pStrComboboxName, pIntComboboxIndex, pStrItemName)
If ComboBoxItem_Exists_ByName(pStrComboboxName, pIntComboboxIndex, pStrItemName) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ComboBoxItem_Exists_ByName", _
"ComboBox Item Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox Name='" & pStrItemName & "'"
Verify_ComboBoxItem_Exists_ByName = PASS
Else
Call REPORT_FAILURE2("Verify_ComboBoxItem_Exists_ByName", _
"ComboBox Item Not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox Name='" & pStrItemName & "'")
Verify_ComboBoxItem_Exists_ByName = FAIL
End If
End Function

Function Verify_ComboBoxItem_NotFound_ByName(pStrComboboxName, pIntComboboxIndex, pStrItemName)
If ComboBoxItem_Exists_ByName(pStrComboboxName, pIntComboboxIndex, pStrItemName) Then
Call REPORT_FAILURE2("Verify_ComboBoxItem_NotFound_ByName", _
"ComboBox Item Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox Name='" & pStrItemName & "'")
Verify_ComboBoxItem_NotFound_ByName = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ComboBoxItem_NotFound_ByName", _
"ComboBox Item Not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox Name='" & pStrItemName & "'"
Verify_ComboBoxItem_NotFound_ByName = PASS
End If
End Function

Function Verify_ComboBox_Exists_ByIndex (pIntComboboxIndex)
If ComboBox_Exists_ByIndex (pIntComboboxIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Combo box with index found: " & pIntComboboxIndex ,"."
Verify_ComboBox_Exists_ByIndex = PASS
Else
Call REPORT_FAILURE2("Combo box with index not found: " & pIntComboboxIndex, _
"Combo box with index not found: " & pIntComboboxIndex)
Verify_ComboBox_Exists_ByIndex = FAIL
End If
End Function

Function Verify_ComboBox_NotFound_ByIndex (pIntComboboxIndex)
If ComboBox_Exists_ByIndex (pIntComboboxIndex) Then
Call REPORT_FAILURE2("Combo box with index found: " & pIntComboboxIndex, _
"Combo box with index found: " & pIntComboboxIndex)
Verify_ComboBox_NotFound_ByIndex = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Combo box with index not found: " & pIntComboboxIndex ,"."
Verify_ComboBox_NotFound_ByIndex = PASS
End If
End Function

Function Count_ComboBox (pStrComboboxName)
dim i_
i_=0
while (ComboBox_Exists(pStrComboboxName, i_))
i_=i_+1
wend
Count_ComboBox = i_
End Function

Function Count_ComboBoxItem(pStrComboboxName, pIntComboboxIndex)
If Not ComboBox_Exists(pStrComboBoxName, pIntComboBoxIndex) Then
Count_ComboBoxItem = 0
Exit Function
End If
Reporter.Filter = rfDisableAll
Count_ComboBoxItem = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboBoxName , "Index:=" & pIntComboBoxIndex).GetROProperty("items count")
End Function

Function Verify_ComboBox_IsEmpty(pStrComboboxName,pIntComboboxIndex)
If Count_ComboBoxItem(pStrComboboxName,pIntComboboxIndex) > 0 Then
Call REPORT_FAILURE2("Verify_ComboBox_IsEmpty:", _
"Combo box is not Empty : Combo box name '" & pStrComboboxName & "'")
Verify_ComboBox_IsEmpty = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Combo box is Empty: " & pStrComboboxName ,"."
Verify_ComboBox_IsEmpty = PASS
End if
End Function


Function Get_SelectedComboBoxItemName(pStrComboboxName, pIntComboboxIndex)
If ComboBox_Exists(pStrComboboxName, pIntComboboxIndex) Then
Reporter.Filter = rfDisableAll
Get_SelectedComboBoxItemName = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboboxName, "Index:=" & pIntComboboxIndex).GetROProperty("value")
Else
Call REPORT_FAILURE2("Get_SelectedComboBoxItemName: could not find object", _
"ComboBox not foundobject name '" & pStrComboboxName & "', Index ='" & pIntComboboxIndex & "'")
Get_SelectedComboBoxItemName = null
End if
End Function

'
'RETURN
' PASS: if there is the specified combobox and the specified comobobox item.
' FAIL: if the function can not find the specified cobobox.
'Example
' Call Set_ComboBoxItem_ByDataName("combo1", 0, "combolist1")
Function Set_ComboBoxItem_ByDataName(pStrComboboxName, pIntComboboxIndex, pStrItemName)
If Not ComboBox_Exists (pStrComboboxName, pIntComboboxIndex) Then
Call REPORT_FAILURE2("Set_ComboBoxItem_ByDataName: Combbox Not Found", _
"ComboBox not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "'")
Set_ComboBoxItem_ByDataName = FAIL
Exit Function
End If
If Not ComboBoxItem_Exists_ByDataName(pStrComboboxName, pIntComboboxIndex, pStrItemName) Then
Call REPORT_FAILURE2("Set_ComboBoxItem_ByDataName: Combbox Item Not Found", _
"ComboBox Item not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox item Name='" & pStrItemName & "'")
Set_ComboBoxItem_ByDataName = FAIL
Exit Function
End If
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboboxName, "Index:=" & pIntComboboxIndex).Select (pStrItemName)

Call REPORT_MSG2("'" & pStrItemName & "' selected", _
"Set_ComboBoxItem_ByDataName selected '" & pStrItemName & "' item in '" & pStrComboboxName & "' combo box")
Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Set_ComboBoxItem_ByDataName = PASS
End Function

Function Set_ComboBoxItem_ByName (pStrComboboxName, pIntComboboxIndex, pStrItemName)
Reporter.Filter = rfDisableAll
dim translated_name_
translated_name_ = Local_Text(pStrItemName)
'This validation is in ComboBoxItem_Exists_ByName function
' If Not (ComboBox_Exists (pStrComboboxName, pIntComboboxIndex)) Then
' Reporter.ReportEvent micFail, "Combo Box not found: " & pStrComboboxName ,". Set_ComboBoxItem_ByName Failed."
' Set_ComboBoxItem_ByName = FAIL
' Exit Function
' End If
If Not ComboBoxItem_Exists_ByName(pStrComboboxName, pIntComboboxIndex, translated_name_) Then
Call REPORT_FAILURE2("Set_ComboBoxItem_ByName", _
"ComboBox Item not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox item Name='" & translated_name_ & "'")
Set_ComboBoxItem_ByName = FAIL
Exit Function
End If

analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboboxName, "Index:=" & pIntComboboxIndex).Select (translated_name_)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & pStrItemName & "' selected" , _
"Set_ComboBoxItem_ByName selected '" & pStrItemName & "' item in '" & pStrComboboxName & "' combo box")

Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Set_ComboBoxItem_ByName = PASS
Reporter.Filter = rfEnableAll
End Function

Function Set_ComboBoxItem_ByIndex (pStrComboboxName, pIntComboboxIndex, pIntItemIndex)
If Not ComboBox_Exists (pStrComboboxName, pIntComboboxIndex) Then
Call REPORT_FAILURE2("Set_ComboBoxItem_ByIndex", _
"ComboBox not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "'")
Set_ComboBoxItem_ByIndex = FAIL
Exit Function
End If
If Not ComboBoxItem_Exists_ByIndex (pStrComboboxName, pIntComboboxIndex, pIntItemIndex) Then
Call REPORT_FAILURE2("Set_ComboBoxItem_ByIndex", _
"ComboBox Item not Found: Combobox Name='" & pStrComboboxName & "' Combobox Index='" & pIntComboboxIndex & "' Combobox item Index='" & pIntItemIndex & "'")
Set_ComboBoxItem_ByIndex = FAIL
Exit Function
End If
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrComboboxName, "Index:=" & pIntComboboxIndex).Select ("#" & pIntItemIndex)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & pIntItemIndex & "' selected" , _
"Set_ComboBoxItem_ByName selected No.'" & pIntItemIndex & "' item in '" & pStrComboboxName & "' combo box")

Sync_Page
analyzePerformance.aend
Set_ComboBoxItem_ByIndex = PASS
End Function

Function Set_ComboBoxItem_ByComboBoxIndex_And_ItemIndex (pIntComboboxIndex, pIntItemIndex)
If Not ComboBox_Exists_ByIndex (pIntComboboxIndex) Then
Call REPORT_FAILURE2("Set_ComboBoxItem_ByComboBoxIndex_And_ItemIndex", _
"ComboBox not Found: Combobox Index='" & pIntComboboxIndex & "'")
Set_ComboBoxItem_ByComboBoxIndex_And_ItemIndex = FAIL
Exit Function
End If
analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Index:=" & pIntComboboxIndex).Select ("#" & pIntItemIndex)
Sync_Page
analyzePerformance.aend
Set_ComboBoxItem_ByComboBoxIndex_And_ItemIndex = PASS
End Function

Function Set_ComboBoxItem_ByComboBoxIndex_And_ItemName (pIntComboboxIndex, pStrItemName)
If Not ComboBox_Exists_ByIndex (pIntComboboxIndex) Then
Call REPORT_FAILURE2("Set_ComboBoxItem_ByComboBoxIndex_And_ItemIndex", _
"ComboBox not Found: Combobox Index='" & pIntComboboxIndex & "'")
Set_ComboBoxItem_ByComboBoxIndex_And_ItemName = FAIL
Exit Function
End If

analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Index:=" & pIntComboboxIndex).Select (pStrItemName)
Call REPORT_MSG2("'" & pStrItemName & "' set", "Set_ComboBoxItem_ByComboBoxIndex_And_ItemName set '" & pStrItemName & "' in index(" & pIntComboboxIndex & ")")

Sync_Page
analyzePerformance.aend
Set_ComboBoxItem_ByComboBoxIndex_And_ItemName = PASS
End Function

Function Verify_ComboBoxDataValue_Selected(pStrComboboxName, pIntComboboxIndex, pStrValue)
Dim actualValue
actualValue=Get_SelectedComboBoxItemName(pStrComboboxName, pIntComboboxIndex)
If actualValue=pStrValue Then
Call REPORT_PASS("Verify_ComboBoxValue_Selected", "ComboBoxValue found: Name = '" & pStrValue & "', is selected'")
Verify_ComboBoxDataValue_Selected = PASS
Else
Call REPORT_FAILURE2("Verify_ComboBoxValue_Selected", "ComboBoxValue selected is '" & actualValue & "', NOT '" & pStrValue & "'.")
Verify_ComboBoxDataValue_Selected = FAIL
End If
End Function

Function Verify_ComboBoxValue_Selected(pStrComboboxName, pIntComboboxIndex, pStrValue)
Dim translated_name_
Dim actualValue
translated_name_ = Local_Text(pStrValue)
actualValue=Get_SelectedComboBoxItemName(pStrComboboxName, pIntComboboxIndex)
If actualValue=translated_name_ Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ComboBoxValue_Selected", _
"ComboBoxValue found: Name = '" & translated_name_ & "', is selected'"
Verify_ComboBoxValue_Selected = PASS
Else
Call REPORT_FAILURE2("Verify_ComboBoxValue_Selected", _
"ComboBoxValue selected is '" & actualValue & "', NOT '" & translated_name_ & "'.")
Verify_ComboBoxValue_Selected = FAIL
End If
End Function
'---------------------------------------------------------------------------------------------
' List Object Section
'---------------------------------------------------------------------------------------------
'No need to be translated.
Function List_Exists(pStrListName, pIntListIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntListIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntListIndex = 0 Then
List_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntListIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntListIndex <> 0 Then
List_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
Reporter.Filter = rfDisableAll
List_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName , "Index:=" & pIntListIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

'No need to be translated.
Function Verify_List_Exists (pStrListName, pIntListIndex)
If List_Exists (pStrListName, pIntListIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_List_Exists", _
"List Found: List Name='" & pStrListName & "' List Index='" & pIntListIndex & "'"
Verify_List_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_List_Exists", _
"List Not Found: List Name='" & pStrListName & "' List Index='" & pIntListIndex & "'")
Verify_List_Exists = FAIL
End If
End Function

Function ListItem_Exists_ByIndex(pStrListName, pIntListIndex, pIntItemIndex)
If pIntItemIndex < Count_ListItem(pStrListName, pIntListIndex) Then
ListItem_Exists_ByIndex = True
Else
ListItem_Exists_ByIndex = False
End If
End Function

'Use this function to verify that number of items in the list is correct
Function Verify_ListItem_Exists_ByIndex(pStrListName, pIntListIndex, pIntItemIndex)
Dim RET
RET = Count_ListItem(pStrListName, pIntListIndex)
If pIntItemIndex = RET Then
Verify_ListItem_Exists_ByIndex = True
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ListItem_Exists_ByIndex", _
"List item number is correct: List Name='" & pStrListName & "' List Index='" & RET & "'"
Else
Verify_ListItem_Exists_ByIndex = False
Call REPORT_FAILURE2("Verify_ListItem_Exists_ByIndex", _
"List item number is NOT correct: List Name='" & pStrListName & "' List Index='" & RET & "'")
End If
End Function

Function ListItem_Exists_ByDataName(pStrListName, pIntListIndex, pStrItemName)
If Not List_Exists(pStrListName, pIntListIndex) Then
ListItem_Exists_ByDataName = False
Exit Function
End If
Dim all_items
Reporter.Filter = rfDisableAll
all_items = SeparateToken(Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName , "Index:=" & pIntListIndex).GetROProperty("all items"), ";")

Dim aitem
ListItem_Exists_ByDataName = False
For Each aitem In all_items
If aitem = pStrItemName Then
ListItem_Exists_ByDataName = True
Exit For
End If
Next
End Function

Function ListItem_Exists_ByName(pStrListName, pIntListIndex, pStrItemName)
dim translated_name_
translated_name_ = Local_Text(pStrItemName)
ListItem_Exists_ByName = ListItem_Exists_ByDataName(pStrListName, pIntListIndex, translated_name_)
End Function

Function Verify_ListItem_Exists_ByDataName(pStrListName, pIntListIndex, pStrItemName)
If ListItem_Exists_ByDataName(pStrListName, pIntListIndex, pStrItemName) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ListItem_Exists_ByDataName", _
"List Item Found: List Name='" & pStrListName & "' List Index='" & pIntListIndex & "' List Item Name='" & pStrItemName & "'"
Verify_ListItem_Exists_ByDataName = PASS
Else
Call REPORT_FAILURE2("Verify_ListItem_Exists_ByDataName", _
"List Item Not Found: List Name='" & pStrListName & "' List Index='" & pIntListIndex & "' List Item Name='" & pStrItemName & "'")
Verify_ListItem_Exists_ByDataName = FAIL
End If
End Function

Function Verify_ListItem_Exists_ByName(pStrListName, pIntListIndex, pStrItemName)
If ListItem_Exists_ByName(pStrListName, pIntListIndex, pStrItemName) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_ListItem_Exists_ByName", _
"List Item Found: List Name='" & pStrListName & "' List Index='" & pIntListIndex & "' List Item Name='" & pStrItemName & "'"
Verify_ListItem_Exists_ByName = PASS
Else
Call REPORT_FAILURE2("Verify_ListItem_Exists_ByName", _
"List Item Not Found: List Name='" & pStrListName & "' List Index='" & pIntListIndex & "' List Item Name='" & pStrItemName & "'")
Verify_ListItem_Exists_ByName = FAIL
End If
End Function

Function Verify_ListItems_Exist_ByName(pStrListName, pIntListIndex, pArrayItemNames)
Dim itemName_
For Each itemName_ in pArrayItemNames
Call Verify_ListItem_Exists_ByName(pStrListName, pIntListIndex, itemName_)
Next
End Function

Function Verify_ListItems_Exist_ByDataName(pStrListName, pIntListIndex, pArrayItemNames)
Dim itemName_
For Each itemName_ in pArrayItemNames
Call Verify_ListItem_Exists_ByDataName(pStrListName, pIntListIndex, itemName_)
Next
End Function

Function Count_List (pStrListName)
dim i_
i_=0
while (List_Exists(pStrListName, i_))
i_=i_+1
wend
Count_List = i_
End Function

Function Count_ListItem(pStrListName, pIntListIndex)
If Not List_Exists(pStrListName, pIntListIndex) Then
Count_ListItem = 0
Exit Function
End If
Reporter.Filter = rfDisableAll
Count_ListItem = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName , "Index:=" & pIntListIndex).GetROProperty("items count")
End Function

Function Get_ListItemOnOff_ByIndex(pStrListName, pIntListIndex, pIntItemIndex)
If Not List_Exists(pStrListName, pIntListIndex) Then
Call REPORT_FAILURE2("Get_ListItemOnOff_ByIndex", _
"List not Found: List Name='" & pStrListName & "' List Index='" & pIntListIndex & "'")
Get_ListItemOnOff_ByIndex = Null
Exit Function
End If

If Not ListItem_Exists_ByIndex(pStrListName, pIntListIndex, pIntItemIndex) Then
Call REPORT_FAILURE2("Get_ListItemOnOff_ByIndex", _
"List Item Not Found: List Name='" & pStrListName & "' List Index='" & pIntListIndex & "' List Item Index='" & pIntItemIndex & "'")
Get_ListItemOnOff_ByIndex = Null
Exit Function
End If
Dim selectedItemIndex_
Reporter.Filter = rfDisableAll
selectedItemIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName , "Index:=" & pIntListIndex).GetROProperty("selected item index")
If inStr(1, selectedItemIndex_, ";" & CStr(pIntItemIndex) & ";", vbTextCompare) <> 0 Then
Get_ListItemOnOff_ByIndex = WEB_OBJECT_ON
Exit Function
End If
If inStr(1, selectedItemIndex_, CStr(pIntItemIndex) & ";", vbTextCompare) <> 0 Then
Get_ListItemOnOff_ByIndex = WEB_OBJECT_ON
Exit Function
End If
If inStr(1, selectedItemIndex_, ";" & CStr(pIntItemIndex), vbTextCompare) <> 0 Then
Get_ListItemOnOff_ByIndex = WEB_OBJECT_ON
Exit Function
End If
If inStr(1, selectedItemIndex_, CStr(pIntItemIndex), vbTextCompare) <> 0 And inStr(1, selectedItemIndex_, ";", vbTextCompare) = 0 Then
Get_ListItemOnOff_ByIndex = WEB_OBJECT_ON
Exit Function
End If
Get_ListItemOnOff_ByIndex = WEB_OBJECT_OFF
' Dim i_
' i_ = 0
' Dim itIsOn_
' itIsOn_ = False
' Do While i_ < Ubound(selectedItemIndexes_)
' If selectedItemIndexes_(i_) = pIntItemIndex Then
' itIsOn_ = True
' Exit Do
' End If
' Loop
'
' If itIsOn_ Then
' Get_ListItemOnOff_ByIndex = WEB_OBJECT_ON
' Else
' Get_ListItemOnOff_ByIndex = WEB_OBJECT_OFF
' End If
End Function

'No need to translate
Function Set_ListItem_ByDataName(pStrListName, pIntListIndex, pStrItemName, pStrOnOrOff)
If Not List_Exists (pStrListName, pIntListIndex) Then
Call REPORT_FAILURE2("LIst not found: " & pStrListName, _
"Set_ListItem_ByDataName could not find " & pStrListName & " list.")
Set_ListItem_ByDataName = FAIL
Exit Function
End If
If Not ListItem_Exists_ByDataName(pStrListName, pIntListIndex, pStrItemName) Then
Call REPORT_FAILURE2("LIst Item not found: " & pStrListName & " item name = '" & pStrItemName & "'", _
"LIst Item not found: " & pStrListName & " item name = '" & pStrItemName & "'")
Set_ListItem_ByDataName = FAIL
Exit Function
End If

analyzePerformance.start
Reporter.Filter = rfDisableAll
If pStrOnOrOff = WEB_OBJECT_ON Then
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName, "Index:=" & pIntListIndex).ExtendSelect (pStrItemName)
Call REPORT_MSG2("'" & pStrItemName & "' selected", _
"Set_ListItem_ByDataName selected '" & pStrItemName & "' item in '" & pStrListName & "' list box")
Else
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName, "Index:=" & pIntListIndex).Deselect (pStrItemName)
Call REPORT_MSG2("'" & pStrItemName & "' deselected", _
"Set_ListItem_ByDataName deselected '" & pStrItemName & "' item in '" & pStrListName & "' list box")

End If

Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Set_ListItem_ByDataName = PASS

End Function

Function Set_ListItem_ByName(pStrListName, pIntListIndex, pStrItemName, pStrOnOrOff)
dim translated_name_
translated_name_ = Local_Text(pStrItemName)
Set_ListItem_ByName = Set_ListItem_ByDataName(pStrListName, pIntListIndex, translated_name_, pStrOnOrOff)
End Function

Function Set_ListItem_ByIndex(pStrListName, pIntListIndex, pIntItemIndex, pStrOnOrOff)
If Not List_Exists (pStrListName, pIntListIndex) Then
Call REPORT_FAILURE2("LIst '" & pStrListName & "' not found", _
"'Set_ListItem_ByIndex could not found list name = '" & pStrListName & "'")
Set_ListItem_ByIndex = FAIL
Exit Function
End If
If Not ListItem_Exists_ByIndex(pStrListName, pIntListIndex, pIntItemIndex) Then
Call REPORT_FAILURE2("LIst Item index " & pIntItemIndex & "not found", _
"'Set_ListItem_ByIndex could not found list name = '" & pStrListName & "' item index = '" & pIntItemIndex & "'")
Set_ListItem_ByIndex = FAIL
Exit Function
End If

analyzePerformance.start
Reporter.Filter = rfDisableAll
If pStrOnOrOff = WEB_OBJECT_ON Then
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName, "Index:=" & pIntListIndex).ExtendSelect ("#" & pIntItemIndex)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & pIntItemIndex & "' selected" , _
"Set_ListItem_ByIndex selected '" & pIntItemIndex & "' item in '" & pStrListName & "' list box")
Else
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName, "Index:=" & pIntListIndex).Deselect ("#" & pIntItemIndex)
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & pIntItemIndex & "' deselected" , _
"Set_ListItem_ByIndex deselected '" & pIntItemIndex & "' item in '" & pStrListName & "' list box")
End If

Sync_Page
analyzePerformance.aend
Set_ListItem_ByIndex = PASS
End Function

' Handling multiple Items in a list
'Specify a list and select all items in the list
Function Select_All_ListItems(pStrListName, pIntListIndex)
Dim existingColumnNumber
existingColumnNumber = Count_ListItem(pStrListName, pIntListIndex)

Dim currentNumber
For currentNumber = 0 To existingColumnNumber - 1
Call Set_ListItem_ByIndex(pStrListName, pIntListIndex, currentNumber, WEB_OBJECT_ON)
Next
End Function

'Specify a list and deselect all items in the list
Function Deselect_All_ListItems(pStrListName, pIntListIndex)
Dim existingColumnNumber
existingColumnNumber = Count_ListItem(pStrListName, pIntListIndex)

Dim currentNumber
For currentNumber = 0 To existingColumnNumber - 1
Call Set_ListItem_ByIndex(pStrListName, pIntListIndex, currentNumber, WEB_OBJECT_OFF)
Next
End Function

'USAGE
' Call Select_ListItems_ByDataName("unselectedItems", 0, Array("Resource", "Overall", "Job", "Qualifications", "Gantt View", "Skills", "Education", "Certifications", "Pool", "Workwekk", "Job Title"))
Function Select_ListItems_ByDataName(pStrListName, pIntListIndex, pAryStrItemNames)

Call Deselect_All_ListItems(pStrListName, pIntListIndex)

Dim strItemName_

For Each strItemName_ in pAryStrItemNames
Call Set_ListItem_ByDataName(pStrListName, pIntListIndex, strItemName_, WEB_OBJECT_ON)
Next

End Function

'USAGE
' Call Select_ListItems_ByRegExp("ixn_transferCostFinder_fromActivities", 0, ".* \(pos155245\)", True)
' Call Select_ListItems_ByRegExp("ixn_transferCostFinder_fromActivities", 0, ".*Billable.*", False)
' Call Select_ListItems_ByRegExp("ixn_transferCostFinder_toActivities", 0, ".*billable.*", True)
Function Select_ListItems_ByRegExp(pStrListName, pIntListIndex, pStrItemRegExpPattern, pBlnIgnoreCase)
If Not List_Exists (pStrListName, pIntListIndex) Then
Call REPORT_FAILURE2("LIst not found: " & pStrListName, _
"Select_ListItems_ByRegExp could not find " & pStrListName & " list.")
Select_ListItems_ByRegExp = FAIL
Exit Function
End If

Dim objRegExp ' Create variable.
Set objRegExp = New RegExp ' Create a regular expression.
objRegExp.Pattern = pStrItemRegExpPattern ' Set pattern.
objRegExp.IgnoreCase = pBlnIgnoreCase ' Set case insensitivity.
objRegExp.Global = True ' Set global applicability.

Dim aryStrItemNames
aryStrItemNames = SeparateToken(Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebList("Name:=" & pStrListName , "Index:=" & pIntListIndex).GetROProperty("all items"), ";")

Dim index
For index = 0 To Ubound(aryStrItemNames)
If objRegExp.Test(aryStrItemNames(index)) Then
Call Set_ListItem_ByIndex(pStrListName, pIntListIndex, index, WEB_OBJECT_ON)
Call REPORT_MSG("Select_ListItems_ByRegExp: '" & aryStrItemNames(index) & "' selected")
End If
Next

Set objRegExp = Nothing

End Function ' End Of Select_ListItems_ByRegExp







'---------------------------------------------------------------------------------------------
' IFrame Object Section
'---------------------------------------------------------------------------------------------
Function IFrameButton_Exists(pStrButtonName, pIntButtonIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Frame("name:=~messageIFrame").WebButton("Name:=" & pStrButtonName).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntButtonIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntButtonIndex = 0 Then
IFrameButton_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntButtonIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntButtonIndex <> 0 Then
IFrameButton_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
IFrameButton_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Frame("name:=~messageIFrame").WebButton("Name:=" & pStrButtonName, "Index:=" & pIntButtonIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Verify_IFrameButton_Exists(pStrButtonName, pIntButtonIndex)
If IFrameButton_Exists(pStrButtonName, pIntButtonIndex) Then
Call REPORT_PASS("Verify_IFrameButton_Exists '" & pStrButtonName & "'(" & pIntButtonIndex & ")", _
"Verify_IFrameButton_Exists '" & pStrButtonName & "'(" & pIntButtonIndex & ")")
Verify_IFrameButton_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_IFrameButton_Exists FAILED '" & pStrButtonName & "'(" & pIntButtonIndex & ")", _
"Verify_IFrameButton_Exists FAILED '" & pStrButtonName & "'(" & pIntButtonIndex & ") does not exist")
Verify_IFrameButton_Exists = FAIL
End If
End Function

Function Verify_IFrameButton_NotFound(pStrButtonName, pIntButtonIndex)
If IFrameButton_Exists(pStrButtonName, pIntButtonIndex) Then
Call REPORT_FAILURE2("Verify_IFrameButton_NotFound '" & pStrButtonName & "'(" & pIntButtonIndex & ")", _
"Verify_IFrameButton_NotFound '" & pStrButtonName & "'(" & pIntButtonIndex & ") was found")
Verify_IFrameButton_NotFound = FAIL
Else
Call REPORT_PASS("Verify_IFrameButton_NotFound FAILED '" & pStrButtonName & "'(" & pIntButtonIndex & ")", _
"Verify_IFrameButton_NotFound FAILED '" & pStrButtonName & "'(" & pIntButtonIndex & ") does not exist")
Verify_IFrameButton_NotFound = PASS
End If
End Function






Function Click_IFrameButton(pStrButtonName, pIntButtonIndex)
dim translated_name_
translated_name_ = Local_Text(pStrButtonName)
If Not IFrameButton_Exists (pStrButtonName, pIntButtonIndex) Then
Call REPORT_FAILURE2("'" & pStrButtonName & "' iframe button not found", _
"Click_IFrameButton: could not find '" & translated_name_ & "' iframe button")
Click_IFrameButton = FAIL
Exit Function
End If

analyzePerformance.start
Reporter.Filter = rfDisableAll
Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Frame("name:=~messageIFrame").WebButton("Name:=" & translated_name_, "Index:=" & pIntButtonIndex).Click
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"'" & translated_name_ & "' clicked" , _
"Click_IFrameButton clicked '" & translated_name_ & "' button in Iframe")

Sync_Page 'Browser("hwnd:=" & hWindow).Sync
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
Click_IFrameButton = PASS
End Function

Function IFrame_WebTable_Exists(text)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
IFrame_WebTable_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Frame("name:=~messageIFrame").WebTable("text:=" & text & ".*").Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function IFrame_Verify_WebTable_Exists(text)
'Call Initiate_wHandle ' make sure hWindow is known Commented by Venkat... Initiate_wHandle function calling in IFrame_WebTable_Exists
If IFrame_WebTable_Exists(text) then
Call REPORT_PASS("IFrame_Verify_WebTable_Exists", "WebTable found: WebTable name = '" & text & "'")
IFrame_Verify_WebTable_Exists = PASS
else
Call REPORT_FAILURE2("IFrame_Verify_WebTable_Exists", "WebTable Not Found: WebTable name = '" & text & "'")
IFrame_Verify_WebTable_Exists = FAIL
end if
End Function

Function IFrame_Verify_WebTable_NotFound(text)
'Call Initiate_wHandle ' make sure hWindow is known Commented by Venkat... Initiate_wHandle function calling in IFrame_WebTable_Exists
If IFrame_WebTable_Exists(text) then
Call REPORT_FAILURE2("IFrame_Verify_WebTable_NotFound", "WebTable FOUND: WebTable name = '" & text & "'")
IFrame_Verify_WebTable_NotFound = FAIL
else
Call REPORT_PASS("IFrame_Verify_WebTable_NotFound", "WebTable Not Found: WebTable name = '" & text & "'")
IFrame_Verify_WebTable_NotFound = PASS
end if
End Function

'---------------------------------------------------------------------------------------------
' HTML Text (WebElement) Object Section
'---------------------------------------------------------------------------------------------
'OPEN_ISSUE ***********************
' should use regular expression?
'OPEN_ISSUE ***********************
'OPEN_ISSUE ******************
' Do we need to have Text_Exists(pStrBeforeText, pStrAfterText, pStrTextChecked)?
'OPEN_ISSUE ******************

'Look for the specified word whole html file and
Function DataText_Exists(pStrName, pIntIndex)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
DataText_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebElement("innertext:=" & pStrName , "index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function Text_Exists(pStrName, pIntIndex)
Dim translated_name_
Call Initiate_wHandle ' make sure hWindow is known
translated_name_ = Local_Text(pStrName)
Reporter.Filter = rfDisableAll
Text_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebElement("innertext:=" & translated_name_ , "index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
' Dim existenceWithoutRegularExp_
' existenceWithoutRegularExp_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebElement("innertext:=" & translated_name_ , "index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
' If existenceWithoutRegularExp_ Then
' Text_Exists = True
' Else
' 'Regular Expression
' Dim innerText_
' innerText_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebElement("innertext:=" & translated_name_ & "").GetROProperty("items count")
'
' Dim regEx_, Matches_
' Set regEx_ = New RegExp ' Create regular expression.
' regEx_.Pattern = translated_name_ ' Set pattern.
' regEx_.IgnoreCase = False ' Set case sensitivity.
' regEx_.Global = True ' Set global applicability.
' Set Matches_ = regEx_.Execute(innerText_) ' Execute search.
' Dim count_
' For Each Match in Matches ' Iterate Matches collection.
' count_ = count_ + 1
' Next
'
' If pIntIndex < count_ Then
' Text_Exists = True
' Else
' Text_Exists = False
' End If
'
' End If
End Function

Function Verify_Text_Exists(pStrContext, pIntContextIndex) ' open issue: pIntContextIndex IS required...
' Call REPORT_WARNING("Verify_Text_Exists function should be replaced with Verify_WebTable_Cell function!")
If Text_Exists (pStrContext, pIntContextIndex) Then
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass, _
"Verify_Text_Exists" , _
"the context('" & pStrContext & "') has been found")
Verify_Text_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_Text_Exists not found a context '" & pStrContext & "'" , _
"the context('" & pStrContext & "') was not found")
Verify_Text_Exists = FAIL
End If
End Function

Function Verify_Text_NotFound(pStrContext, pIntContextIndex) ' open issue: pIntContextIndex IS required...
If Text_Exists (pStrContext, pIntContextIndex) Then
Call REPORT_FAILURE2("Verify_Text_NotFound" , _
"the context('" & pStrContext & "') has been found")
Verify_Text_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass, _
"Verify_Text_NotFound" , _
"the context('" & pStrContext & "') was not found")
Verify_Text_NotFound = PASS
End If
End Function


Function Verify_DataText_Exists(pStrContext, pIntContextIndex) ' open issue: pIntContextIndex IS required...
' Call REPORT_WARNING("Verify_DataText_Exists function should be replaced with Verify_WebTable_Cell function!") '09/26/06, Max: commented out (we will not be replacing it with more complex functions)
If DataText_Exists (pStrContext, pIntContextIndex) Then
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass, _
"Verify_DataText_Exists" , _
"the context('" & pStrContext & "') has been found")
Verify_DataText_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_DataText_Exists not found a context '" & pStrContext & "'" , _
"the context('" & pStrContext & "') was not found")
Verify_DataText_Exists = FAIL
End If
End Function

Function Verify_DataText_NotFound(pStrContext, pIntContextIndex) ' open issue: pIntContextIndex IS required...
If DataText_Exists (pStrContext, pIntContextIndex) Then
Call REPORT_FAILURE2("Verify_DataText_NotFound" , _
"the context('" & pStrContext & "') has been found")
Verify_DataText_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass, _
"Verify_DataText_NotFound" , _
"the context('" & pStrContext & "') was not found")
Verify_DataText_NotFound = PASS
End If
End Function




Function Verify_Texts_Exists(pArrayTexts)
Dim Text_
For Each Text_ in pArrayTexts
Call Verify_Text_Exists(Text_, 0)
Next
End Function

'---------------------------------------------------------------------------------------------
' WebTable Object section
'---------------------------------------------------------------------------------------------
' NOTE1: there is NO translation with this function. User responcible for translation!!!!
' NOTE2: we have not fully tested this function in case when only one table with this name is available to the end user
Function WebTable_Exists(text, index)
if Table_Verify then
'check existence without index parameter.
Dim existenceWithoutIndex_
'Call Initiate_wHandle ' make sure hWindow is known

' Deleted by Jun 08/04/2006
' Call REPORT_WARNING("WebTable_Exists function does not call Initiate_wHandle function to improve performance of GetRowIndex_AccordingValue_InTable function.") 'this needs to be addressed later. Max, 03/29/05

Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & text & ".*").Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and index is set 0, this function returns True
If existenceWithoutIndex_ And index = 0 Then
WebTable_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and index is NOT set 0, this function returns False
If existenceWithoutIndex_ And index <> 0 Then
WebTable_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
If Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & text & ".*", "Index:=" & index).Exist(OBJECT_EXIST_TIME_OUT) Then
WebTable_Exists = True
else
WebTable_Exists = False
End If
Reporter.Filter = rfEnableAll
else
WebTable_Exists = True
end if
End Function

Function Verify_WebTable_Exists(text, index)
If WebTable_Exists(text, index) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_WebTable_Exists", _
"WebTable found: WebTable name = '" & text & "' WebTable index ='" & index & "'"
Verify_WebTable_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_WebTable_Exists", _
"WebTable Not Found: WebTable name = '" & text & "' WebTable index ='" & index & "'")
Verify_WebTable_Exists = FAIL
End If
End Function

Function Verify_WebTable_NotFound(text, index)
If WebTable_Exists (text, index) Then
Call REPORT_FAILURE2("Verify_WebTable_NotFound", _
"WebTable FOUND: WebTable name = '" & text & "' WebTable index ='" & index & "'")
Verify_WebTable_NotFound = PASS
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, _
"Verify_WebTable_NotFound", _
"WebTable Not Found: WebTable name = '" & text & "' WebTable index ='" & index & "'"
Verify_WebTable_NotFound = FAIL
End If
End Function

Function WebTable_Cell_Exsists(pStrTableName, pIntTableIndex, row, col)
If Not WebTable_Exists (pStrTableName, pIntTableIndex) Then
WebTable_Cell_Exsists = False
Exit Function
End If

Dim cellValue_
Reporter.Filter = rfDisableAll
cellValue_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:="& pStrTableName & ".*", "Index:=" & pIntTableIndex).GetCellData (row, col)

If cellValue_ = micCellDoesNotExist Then
WebTable_Cell_Exsists = False
Else
WebTable_Cell_Exsists = True
End If

End Function

Function Verify_WebTable_Cell_Exsists(pStrTableName, pIntTableIndex, row, col)
If WebTable_Cell_Exsists(pStrTableName, pIntTableIndex, row, col) Then
Call REPORT_PASS("Verify_WebTable_Cell_Exsists", _
"Web Table cell(" & row & "," & col & ") Found in '" & pStrTableName & "', '" & pIntTableIndex & "'")
Verify_WebTable_Cell_Exsists = PASS
Else
Call REPORT_FAILURE2("Verify_WebTable_Cell_Exsists", _
"Web Table cell(" & row & "," & col & ") Not Found in '" & pStrTableName & "', '" & pIntTableIndex & "'")
Verify_WebTable_Cell_Exsists = FAIL
End If
End Function

Function Verify_WebTable_Cell_NotFound(pStrTableName, pIntTableIndex, row, col)
If WebTable_Cell_Exsists(pStrTableName, pIntTableIndex, row, col) Then
Call REPORT_FAILURE2("Verify_WebTable_Cell_NotFound", _
"Web Table cell(" & row & "," & col & ") Found in '" & pStrTableName & "', '" & pIntTableIndex & "'")
Verify_WebTable_Cell_NotFound = FAIL
Else
Call REPORT_PASS("Verify_WebTable_Cell_NotFound", _
"Web Table cell(" & row & "," & col & ") Not Found in '" & pStrTableName & "', '" & pIntTableIndex & "'")
Verify_WebTable_Cell_NotFound = PASS
End If
End Function


' NOTE:case when index is 0 is NOTcovered!!!!
Function Get_WebTable_Cell(text, index, row, col)
If Not WebTable_Exists(text, index) Then
Call REPORT_FAILURE2("Get_WebTable_Cell: WebTable not found: " & text , _
"Get_WebTable_Cell failed and could not found WebTable '" & text & "'")
Get_WebTable_Cell = FAIL
Exit Function
End If

Dim cellValue_
Reporter.Filter = rfDisableAll
cellValue_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:="& text & ".*", "Index:=" & index).GetCellData (row, col)

If cellValue_ = micCellDoesNotExist Then
Call REPORT_FAILURE2("Get_WebTable_Cell: WebTable cell (" & row & "," & col & ") does not exist", _
"Get_WebTable_Cell coud not get a value from cell (" & row & "," & col & ") in " & text & " table because the cell does not exist")
Get_WebTable_Cell = FAIL
Else
Get_WebTable_Cell = cellValue_
End If
End Function

Function Verify_WebTable_Cell(text, index, row, col, pStrValue)
'Dim translated_name_
Dim actualValue
'translated_name_ = Local_Text(pStrValue)
actualValue=Trim(Get_WebTable_Cell(text, index, row, col))
'If actualValue=translated_name_ Then
If actualValue=Trim(pStrValue) Then
Call REPORT_PASS("Verify_WebTable_Cell('" & text & "', '" & row & "', '" & col & "')", "WebTable_CellValue found: Name = '" & pStrValue & "', is shown'")
Verify_WebTable_Cell = PASS
Else
Call REPORT_FAILURE2("Verify_WebTable_Cell('" & text & "', '" & row & "', '" & col & "')", "WebTable_CellValue shown is '" & actualValue & "', NOT '" & pStrValue & "'.")
Verify_WebTable_Cell = FAIL
End If
End Function

' tableData
' USAGE
' ' if you don't want to verify a cell , then you need to set "null"
' Dim tableData
' tableData = Array( _
' Array(null), _
' Array(null, "Imported Skill101", "Imported Scale1 Level4", "Desired", "Skill"), _
' Array(null, "Imported Skill101", "Imported Scale1 Level2", "Needed", "Skill"), _
' Array(null, "Imported Skill102", "Imported Scale2 Level4", "Needed", "Skill"), _
' Array(null, "Imported Skill102", "Imported Scale2 Level2", "Actual", "Skill"), _
' Array(null, "Imported Skill103", "Imported Scale3 Level4", "Desired", "Skill"), _
' Array(null, "Imported Skill103", "Imported Scale3 Level2", "Actual", "Skill"), _
' Array(null, "Imported Education201", "Imported Scale3 Level4", "Desired", "Education"), _
' Array(null, "Imported Education201", "Imported Scale3 Level2", "Needed", "Education"), _
' Array(null, "Imported Education202", "Imported Scale2 Level4", "Needed", "Education"), _
' Array(null, "Imported Education202", "Imported Scale2 Level2", "Actual", "Education"), _
' Array(null, "Imported Education203", "Imported Scale1 Level4", "Desired", "Education"), _
' Array(null, "Imported Education203", "Imported Scale1 Level2", "Actual", "Education"), _
' Array(null, "Imported Certification201", null, "Actual", "Certification"), _
' Array(null, "Imported Certification202", null, "Desired", "Certification"), _
' Array(null, "Imported Certification203", null, "Needed", "Certification"), _
' Array(null, "Microsoft", null, "Needed", "Certification") _
' )
'
' Call Verify_WebTable_Cells("Name", 0, tableData)
'RETURN
' PASS if all PASS
' FAIL if any FAIL
Function Verify_WebTable_Cells(pStrText, pIntIndex, pArytableData)
Dim anyFail
anyFail = false
Dim rowIndex_, columnIndex_
For rowIndex_= 0 To Ubound(pArytableData)
For columnIndex_ = 0 To Ubound(pArytableData(rowIndex_))
If Not IsNull(pArytableData(rowIndex_ )(columnIndex_)) Then
'msgbox rowIndex_ & "," & columnIndex_ & ":" & pArytableData(rowIndex_ )(columnIndex_)
If Verify_WebTable_Cell(pStrText, pIntIndex, rowIndex_ + 1, columnIndex_ + 1, pArytableData(rowIndex_ )(columnIndex_)) = FAIL Then
anyFail = true
End If
End If
Next
Next

If anyFail Then
Verify_WebTable_Cells = FAIL
Else
Verify_WebTable_Cells = PASS
End If

End Function

Function Verify_WebTable_Cell_NotEqual(text, index, row, col, pStrValue)
Dim actualValue
actualValue=Trim(Get_WebTable_Cell(text, index, row, col))
If actualValue=Trim(pStrValue) Then
Call REPORT_FAILURE2("Verify_WebTable_Cell_NotEqual('" & text & "', '" & row & "', '" & col & "')", "Verify_WebTable_Cell_NotEqual '" & actualValue & "' shown")
Verify_WebTable_Cell_NotEqual = FAIL
Else
Call REPORT_PASS("Verify_WebTable_Cell_NotEqual('" & text & "', '" & row & "', '" & col & "')", "Verify_WebTable_Cell_NotEqual '" & pStrValue & "', is Not shown'")
Verify_WebTable_Cell_NotEqual = PASS
End If
End Function







Function Get_WebTable_RowCount(text, index)
If WebTable_Exists(text, index) Then
Reporter.Filter = rfDisableAll
Get_WebTable_RowCount = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:="& text & ".*", "Index:=" & index).RowCount

Else
Call REPORT_FAILURE2("WebTable not found: " & text ,". Get_WebTable_RowCount Failed.")
Get_WebTable_RowCount = FAIL
End If
End Function

Function Get_WebTable_ColumnCount(text, index)
If WebTable_Exists(text, index) Then
Reporter.Filter = rfDisableAll
Get_WebTable_ColumnCount = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:="& text & ".*", "Index:=" & index).ColumnCount(1) ' modified as per syntax by Venkat
Else
Call REPORT_FAILURE2("WebTable not found: " & text ,". Get_WebTable_ColumnCount Failed.")
Get_WebTable_ColumnCount = FAIL
End If
End Function

' returns row number where your value is shown. index is for tables where headers are in first row.
' diff should be 0 if you don't care. usually, you put diff other then 0 if you want to use valye returned
' diff should be NEGATIVE if you need to offset it to use with other functions (like one below)
' by this function for some other reasons - like selecting check box for project on projecct list page acoording
' to some project property shown - project name etc
' ALSO: if you want to use value returned by this function for some other operations (like selecting checkbox),
' please remember that check box index starts with 0, but row numbers start with 1, so you might want to deduct one
' from returned index
Function GetRowIndex_AccordingValue_InTable(text, index, column_number, value_to_find, diff)
Dim temp_diff, row_number, i, row_count, value_current, temp_val
Call FUNCTION_START("GetRowIndex_AccordingValue_InTable")
If diff<>0 Then
temp_diff = diff
else
temp_diff = 0
End If
row_count = Get_WebTable_RowCount(text, index)

Reporter.Filter = rfDisableAll
temp_val = temp_val
Table_Verify = FALSE
For i=1 To row_count
value_current = Get_WebTable_Cell(text, index, i, column_number)
'Msgbox "Value Current : " & value_current & "and Value to find : " & value_to_find
If Trim(value_current) = Trim(value_to_find) Then
GetRowIndex_AccordingValue_InTable = i + temp_diff
Reporter.Filter = rfEnableAll
Call FUNCTION_END("GetRowIndex_AccordingValue_InTable, PASS")
Exit Function
End If
Next
Reporter.Filter = rfEnableAll
GetRowIndex_AccordingValue_InTable = -99 ' fail to find value in the table
Call REPORT_FAILURE("Failed to locate row number - probably text is not in the table?.. Column number is invalid?...")
Call FUNCTION_END("GetRowIndex_AccordingValue_InTable, FAIL")
Table_Verify = temp_val
End Function
' same as above, but for longer lists (user should decide search direction. if value expected to be at the bottom half of the long list, use this function)
Function GetRowIndex_AccordingValue_InTable_BackwardSearch(text, index, column_number, value_to_find, diff)
Dim temp_diff, row_number, i, row_count, value_current, temp_val
Call FUNCTION_START("GetRowIndex_AccordingValue_InTable_BackwardSearch")
If diff<>0 Then
temp_diff = diff
else
temp_diff = 0
End If
row_count = Get_WebTable_RowCount(text, index)
Reporter.Filter = rfDisableAll
temp_val = temp_val
Table_Verify = FALSE
For i=row_count To 1 Step -1
value_current = Get_WebTable_Cell(text, index, i, column_number)
If Trim(value_current) = Trim(value_to_find) Then
GetRowIndex_AccordingValue_InTable_BackwardSearch = i + temp_diff
Call FUNCTION_END("GetRowIndex_AccordingValue_InTable_BackwardSearch")
Reporter.Filter = rfEnableAll
Exit Function
End If
Next
GetRowIndex_AccordingValue_InTable_BackwardSearch = -99 ' fail to find value in the table
Call REPORT_FAILURE("Failed to locate row number - probably text is not in the table?.. Column number is invalid?...")
Call FUNCTION_END("GetRowIndex_AccordingValue_InTable_BackwardSearch")
Reporter.Filter = rfEnableAll
Table_Verify = temp_val
End Function

' NOTE: it is important to remember about DIFF parameter in this case!!!!!
' also - we need to pass radio button group number, which is known to script creator
Function SetRadioButton_AccordingValue_InTable(text, index, column_number, value_to_find, pStrGroupName, diff)
Dim row_number
Call FUNCTION_START("CheckRadioButton_AccordingValue_InTable")
row_number = GetRowIndex_AccordingValue_InTable(text, index, column_number, value_to_find, diff)
if row_number = -99 then
call REPORT_FAILURE("Failed to find correct row with your input value, this function has to exit.")
SetRadioButton_AccordingValue_InTable = FAIL
call FUNCTION_END("SetRadioButton_AccordingValue_InTable")
exit function
end if
If row_number >= 0 Then
SetRadioButton_AccordingValue_InTable = Set_RadioButtonOn_ByIndex(pStrGroupName, row_number)
else
call REPORT_FAILURE("Could not find value in the table. Was looking for: " & value_to_find)
SetRadioButton_AccordingValue_InTable = FAIL
End If
Call FUNCTION_END("CheckRadioButton_AccordingValue_InTable")
End Function

' NOTE: it is important to remember about DIFF parameter in this case!!!!!
' also - we need to pass radio button group number, which is known to script creator
Function SetCheckBox_AccordingValue_InTable(text, index, column_number, value_to_find, pStrGroupName, diff)
Dim row_number
Call FUNCTION_START("SetCheckBox_AccordingValue_InTable")
row_number = GetRowIndex_AccordingValue_InTable(text, index, column_number, value_to_find, diff)
if row_number = -99 then
call REPORT_FAILURE("Failed to find correct row with your input value, this function has to exit.")
SetCheckBox_AccordingValue_InTable = FAIL
call FUNCTION_END("SetCheckBox_AccordingValue_InTable")
exit function
end if
If row_number >= 0 Then
SetCheckBox_AccordingValue_InTable = Set_CheckBoxOnOff_ByIndex(pStrGroupName, row_number, "ON") '??? is this correct???
else
call REPORT_FAILURE("Could not find value in the table. Was looking for: " & value_to_find)
SetCheckBox_AccordingValue_InTable = FAIL
End If
Call FUNCTION_END("SetCheckBox_AccordingValue_InTable")
End Function

' This sets a checkbox (assuming only one link exists in a cell) that locates on a column specified
' as pIntColumnNumberOfCheckbox and on a row where pStrLookUpText.is found in pIntLookUpColumnNumber column.
' Similar to SetCheckBox_AccordingValue_InTable except:
' 1. you can directly choose the number of column.(No offset)
' 2. Checkbox name does not have to be specified. (again this clicks A checkbox in the given cell)
' 3. You can specify if you check or uncheck the found checkbox
'USAGE
' in Client Finder
' Call Click_Link("Find",0)
' Call Set_Associated_Checkbox_InTable("Client*", 3, 2, CLIENT_NAME_1, 1,"ON")
Function Set_Associated_CheckBox_InTable(pStrTableName, pIntTableIndex, pIntLookUpColumnNumber, pStrLookUpText, pIntColumnNumberOfCheckbox, pStrOnOrOff)
Call FUNCTION_START("Set_Associated_CheckBox_InTable")

Dim lookUpTextRowNumber_
lookUpTextRowNumber_ = GetRowIndex_AccordingValue_InTable(pStrTableName, pIntTableIndex, pIntLookUpColumnNumber, pStrLookUpText, 0)
if lookUpTextRowNumber_ < 0then
Call REPORT_FAILURE("Failed to find correct row with your input value, this function has to exit.")
Set_Associated_CheckBox_InTable = FAIL
Call FUNCTION_END("Set_Associated_CheckBox_InTable")
Exit function
End If

Dim objTargetTable_
Set objTargetTable_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:="& pStrTableName & ".*", "Index:=" & pIntTableIndex)

' If the specified pIntColumnNumberOfCheckbox is not valid
If objTargetTable_.GetCellData(lookUpTextRowNumber_, pIntColumnNumberOfCheckbox) = micCellDoesNotExist Then
Call REPORT_FAILURE("Set_Associated_CheckBox_InTable : cell (" & lookUpTextRowNumber_ & ", " & pIntColumnNumberOfCheckbox & ") does not exist")
Set_Associated_CheckBox_InTable = FAIL
Call FUNCTION_END("Set_Associated_CheckBox_InTable")
Set objTargetTable_ = Nothing
Exit function
End If

' If there is no checkbox to set
If objTargetTable_.ChildItemCount(lookUpTextRowNumber_, pIntColumnNumberOfCheckbox, "WebCheckBox") <= 0 Then
Call REPORT_FAILURE("Set_Associated_CheckBox_InTable : There is no checkbox object in a cell (" & lookUpTextRowNumber_ & ", " & pIntColumnNumberOfCheckbox & ")")
Set_Associated_CheckBox_InTable = FAIL
Call FUNCTION_END("Set_Associated_CheckBox_InTable")
Set objTargetTable_ = Nothing
Exit function
End If

Reporter.Filter = rfDisableAll
objTargetTable_.ChildItem(lookUpTextRowNumber_, pIntColumnNumberOfCheckbox, "WebCheckBox", 0).Set pStrOnOrOff
Call REPORT_MSG("Set_Associated_CheckBox_InTable clicked '" & objTargetTable_.ChildItem(lookUpTextRowNumber_, pIntColumnNumberOfCheckbox, "WebCheckBox", 0).GetROProperty("name") & "' checkbox at a cell(" & lookUpTextRowNumber_ & ", " & pIntColumnNumberToClick & ")")

Set objTargetTable_ = Nothing
Set_Associated_CheckBox_InTable = PASS
Call FUNCTION_END("Set_Associated_CheckBox_InTable")
End Function


' NOTE: value_to_find should come already translated!!! (translate it using Local_Text in your script prior to calling this function)
' NOTE: Link_Name should come already translated!!! (translate it using Local_Text in your script prior to calling this function)
Function Click_Link_AccordingValue_InTable(text, index, column_number, value_to_find, Link_Name, diff_for_rows, diff_for_links)
Call FUNCTION_START("Click_Link_AccordingValue_InTable")
Dim row_number, link_index
row_number = GetRowIndex_AccordingValue_InTable(text, index, column_number, value_to_find, diff_for_rows)
if row_number = -99 then
call REPORT_FAILURE("Failed to find correct row with your input value, this function has to exit.")
Click_Link_AccordingValue_InTable = FAIL
call FUNCTION_END("Click_Link_AccordingValue_InTable")
exit function
end if
link_index = row_number + diff_for_links
If link_index >= 0 Then
'msgBox "link_index = " & link_index
Click_Link_AccordingValue_InTable = Click_DataLink(Link_Name, link_index)
else
call REPORT_FAILURE("Could not find value in the table. Was looking for: " & value_to_find & ". Can not click on link")
Click_Link_AccordingValue_InTable = FAIL
End If
Call FUNCTION_END("Click_Link_AccordingValue_InTable")
End Function

Function Click_Link_AccordingValue_InTable_BackwardSearch(text, index, column_number, value_to_find, Link_Name, diff_for_rows, diff_for_links)
Call FUNCTION_START("Click_Link_AccordingValue_InTable_BackwardSearch")
Dim row_number, link_index
row_number = GetRowIndex_AccordingValue_InTable_BackwardSearch(text, index, column_number, value_to_find, diff_for_rows)
if row_number = -99 then
call REPORT_FAILURE("Failed to find correct row with your input value, this function has to exit.")
Click_Link_AccordingValue_InTable_BackwardSearch = FAIL
call FUNCTION_END("Click_Link_AccordingValue_InTable_BackwardSearch")
exit function
end if
link_index = row_number + diff_for_links
If link_index >= 0 Then
'msgBox "link_index = " & link_index
Click_Link_AccordingValue_InTable_BackwardSearch = Click_DataLink(Link_Name, link_index)
else
call REPORT_FAILURE("Could not find value in the table. Was looking for: " & value_to_find & ". Can not click on link")
Click_Link_AccordingValue_InTable_BackwardSearch = FAIL
End If
Call FUNCTION_END("Click_Link_AccordingValue_InTable_BackwardSearch")
End Function

' This clicks a link (assuming only one link exists in a cell) that locates on a column specified
' as pIntColumnNumberToClick and on a row where pStrLookUpText.is found in pIntLookUpColumnNumber column.
' Similar to Click_Link_AccordingValue_InTable except:
' 1. you can directly choose the number of column.(No offset)
' 2. Link names od not have to be specified. (again this clicks A LINK in the given cell)
'USAGE
' in Team Locator(for example)
' Call Click_Link("Find",0)
' Call Click_Associated_Link_InTable("Position/Task.*", 0, 2, "Project Manager", 3)
Function Click_Associated_Link_InTable(pStrTableName, pIntTableIndex, pIntLookUpColumnNumber, pStrLookUpText, pIntColumnNumberToClick)
Call FUNCTION_START("Click_Associated_Link_InTable")

Dim lookUpTextRowNumber_
lookUpTextRowNumber_ = GetRowIndex_AccordingValue_InTable(pStrTableName, pIntTableIndex, pIntLookUpColumnNumber, pStrLookUpText, 0)
if lookUpTextRowNumber_ < 0then
Call REPORT_FAILURE("Failed to find correct row with your input value, this function has to exit.")
Click_Associated_Link_InTable = FAIL
Call FUNCTION_END("Click_Associated_Link_InTable")
Exit function
End If

Dim objTargetTable_
Set objTargetTable_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:="& pStrTableName & ".*", "Index:=" & pIntTableIndex)

' If the specified pIntColumnNumberToClick is not valid
If objTargetTable_.GetCellData(lookUpTextRowNumber_, pIntColumnNumberToClick) = micCellDoesNotExist Then
Call REPORT_FAILURE("Click_Associated_Link_InTable : cell (" & lookUpTextRowNumber_ & ", " & pIntColumnNumberToClick & ") does not exist")
Click_Associated_Link_InTable = FAIL
Call FUNCTION_END("Click_Associated_Link_InTable")
Set objTargetTable_ = Nothing
Exit function
End If

' If there is no link to click,
If objTargetTable_.ChildItemCount(lookUpTextRowNumber_, pIntColumnNumberToClick, "Link") <= 0 Then
Call REPORT_FAILURE("Click_Associated_Link_InTable : There is no link object in a cell (" & lookUpTextRowNumber_ & ", " & pIntColumnNumberToClick & ")")
Click_Associated_Link_InTable = FAIL
Call FUNCTION_END("Click_Associated_Link_InTable")
Set objTargetTable_ = Nothing
Exit function
End If


Reporter.Filter = rfDisableAll
objTargetTable_.ChildItem(lookUpTextRowNumber_, pIntColumnNumberToClick, "Link", 0).Click
Call REPORT_MSG("Click_Associated_Link_InTable clicked '" & objTargetTable_.ChildItem(lookUpTextRowNumber_, pIntColumnNumberToClick, "Link", 0).GetROProperty("name") & "' link at a cell(" & lookUpTextRowNumber_ & ", " & pIntColumnNumberToClick & ")")

Set objTargetTable_ = Nothing
Click_Associated_Link_InTable = PASS
Call FUNCTION_END("Click_Associated_Link_InTable")
End Function




' NOTE: value_to_find should come already translated!!! (translate it using Local_Text in your script prior to calling this function)
' NOTE: Link_Name should come already translated!!! (translate it using Local_Text in your script prior to calling this function)
Function Click_Image_AccordingValue_InTable(text, index, column_number, value_to_find, Image_Name, diff_for_rows, diff_for_images)
Call FUNCTION_START("Click_Image_AccordingValue_InTable")
Dim row_number, images_index
row_number = GetRowIndex_AccordingValue_InTable(text, index, column_number, value_to_find, diff_for_rows)
if row_number = -99 then
call REPORT_FAILURE("Failed to find correct row with your input value, this function has to exit.")
Click_Image_AccordingValue_InTable = FAIL
call FUNCTION_END("Click_Image_AccordingValue_InTable")
exit function
end if
image_index = row_number + diff_for_images
If link_index >= 0 Then
Click_Image_AccordingValue_InTable = Click_DataImage(Image_Name, image_index)
else
call REPORT_FAILURE("Could not find value in the table. Was looking for: " & value_to_find & ". Can not click on image")
Click_Image_AccordingValue_InTable = FAIL
End If
Call FUNCTION_END("Click_Image_AccordingValue_InTable")
End Function

Function Verify_WebTable_RowCount(pStrWebTableFirstText, pStrWebTableIndex, pIntExpectedRowCount)
Dim intActualRowCount_
intActualRowCount_ = Get_WebTable_RowCount(pStrWebTableFirstText, pStrWebTableIndex)
If intActualRowCount_ = pIntExpectedRowCount Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_WebTable_Row_Count", _
"WebTable row count is '" & pIntExpectedRowCount & "' as expected."
Verify_WebTable_RowCount = PASS
Else
Call REPORT_FAILURE2("Verify_WebTable_Row_Count", _
"WebTable row count is '" & intActualRowCount_ & "', NOT '" & pIntExpectedRowCount & "'.")
Verify_WebTable_RowCount = FAIL
End If
End Function
'---------------------------------------------------------------------------------------------
' WebElement Object section
'---------------------------------------------------------------------------------------------
' NOTE: NO TRANSLATION FOR WEB ELEMENTS!!!!!!!!!!!!!!!!!!
Function WebElement_Exists(pStrWebElementText, pIntWebElementIndex)
'check existence without index parameter.
Dim existenceWithoutIndex_
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
existenceWithoutIndex_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebElement("outertext:=" & pStrWebElementText).Exist(OBJECT_EXIST_TIME_OUT)
'If there is only 1 object and pIntWebElementIndex is set 0, this function returns True
If existenceWithoutIndex_ And pIntWebElementIndex = 0 Then
WebElement_Exists = True
Reporter.Filter = rfEnableAll
Exit Function
End If
'If there is only 1 object and pIntWebElementIndex is NOT set 0, this function returns False
If existenceWithoutIndex_ And pIntWebElementIndex <> 0 Then
WebElement_Exists = False
Reporter.Filter = rfEnableAll
Exit Function
End If
'In the other case, which there is no object or are more than 1.
WebElement_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebElement("outertext:=" & pStrWebElementText, "Index:=" & pIntWebElementIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Verify_WebElement_Exists(pStrWebElementText, pIntWebElementIndex)
If WebElement_Exists (pStrWebElementText, pIntWebElementIndex) Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Verify_WebElement_Exists", _
"WebElement found: WebElement name = '" & pStrWebElementText & "' WebElement index ='" & pIntWebElementIndex & "'"
Verify_WebElement_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_WebElement_Exists", _
"WebElement Not Found: WebElement name = '" & pStrWebElementText & "' WebElement index ='" & pIntWebElementIndex & "'")
Verify_WebElement_Exists = FAIL
End If
End Function

Function Verify_WebElement_NotFound(pStrWebElementText, pIntWebElementIndex)
If WebElement_Exists (pStrWebElementText, pIntWebElementIndex) Then
Call REPORT_FAILURE2("WebElement found: " & pStrWebElementText, _
"WebElement found: " & pStrWebElementText)
Verify_WebElement_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "WebElement not found: " & pStrWebElementText ,""
Verify_WebElement_NotFound = PASS
End If
End Function

Function Click_WebElement(pStrWebElementText, pIntWebElementIndex)
dim ret_
If WebElement_Exists(pStrWebElementText, pIntWebElementIndex) Then
analyzePerformance.start
Reporter.Filter = rfDisableAll
ret_ = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebElement("outertext:=" & pStrWebElementText, "Index:=" & pIntWebElementIndex).Click
Sync_Page
analyzePerformance.aend
Check_For_Error_On_The_Page() ' check for error
if ret_ = True then
Click_WebElement = PASS
end if
Else
Call REPORT_FAILURE2("WebElement not found: " & pStrWebElementText ,". Click_WebElement Failed.")
Click_WebElement = FAIL
End If
End Function

' function below is very usefull in reprots, where it might take some time for text to be available for verification, even after Sync has been completed
function Wait_For_WebElement(pStrWebElementText, pIntWebElementIndex)
dim counter
counter = 0
while Not WebElement_Exists (pStrWebElementText, pIntWebElementIndex)
wait 1
'---------
' Workaround for 42183 (are Actuate reports working - ?)
if not Verify_Dialog_NotFound then
Call Click_WinButton("OK", 0)
Wait_For_WebElement = FAIL
'msgBox '42183'
exit function
end if
'---------
counter = counter +1
if counter > REPORT_MAX_SYNC then
Call REPORT_FAILURE2("WebElement not found after waiting for " & REPORT_MAX_SYNC & " seconds", "pStrWebElementText = " & pStrWebElementText & ", pIntWebElementIndex = " & pIntWebElementIndex)
Wait_For_WebElement = FAIL
exit function
end if
wend
end function
'---------------------------------------------------------------------------------------------
' Browser Object section
'---------------------------------------------------------------------------------------------
Function Open_URL (pStrURL)
If Browser("index:=0").Exist(WINDOW_EXIST_TIME_OUT) then
wHandle1 = Browser("index:=0").GetROProperty("hwnd")
hWindow = wHandle1
Browser("hwnd:=" & hWindow).Navigate(pStrURL)
'msgBox "Opened URL"
Sync_Page 'Browser("hwnd:=" & hWindow).Sync
'wait 2 ' Max: can we avoid wait time here?
Else
'Added by Jun 06/26/2006: automation run always wants a maximize browser since it captures a window image when it fails.
If STAND_ALONE_MODE Then
Call SystemUtil.Run(BROWSER_EXE, pStrURL, "", "open")
Else
Call SystemUtil.Run(BROWSER_EXE, pStrURL, "", "open", 3)
End If

'Call Wait(20) 'Why do we have to wait so much long time? Only Jun's box?
wHandle1 = Browser("index:=0").GetROProperty("hwnd")
hWindow = wHandle1
Sync_Page 'Browser("hwnd:=" & hWindow).Sync
End If

Call REPORT_MSG2("Open_URL", "Open_URL function has opened a url, '" & pStrURL & "'")

End Function

'get URL function goes here
function Get_URL()
' Get the URL of the parent window when there is an error on the child or the parent window
'added index by jun. This was failed when the browser has a google tool bar or similar.
Get_URL = Browser("hwnd:=" & wHandle1).WinEdit("nativeclass:=Edit", "index:=0").GetROProperty("regexpwndtitle")
end function

Public Sub KillProcess (strProcess)
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process Where Name =" & strProcess)
For Each objProcess in colProcesses
objProcess.Terminate()
Next
End Sub

Sub Close_Browser
Browser("hwnd:=" & hWindow).Close
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micDone, _
"Close_Browser" , _
"Closed a window(window handle ='" & hWindow & "')")
If (Browser("title:=.*").Exist) Then
Call Initiate_wHandle ' make sure hWindow is known
End If
End Sub

Sub Close_All_Browsers ' also need to kill process for browsers
Dim numberOfBrowsers_
Dim index_
Reporter.Filter = rfDisableAll
Do While(True)
If Not Browser("index:=0").Exist(WINDOW_EXIST_TIME_OUT) Then
Exit Do
End If
Browser("index:=0").Close
If URL_FLAG <> "CORE" then
wait 7 'this is needed to improve stability of this function - it constantly used to fail when loging in to Core app after PM/BI actions.
End if
Loop
' numberOfBrowsers_ = Count_Browsers()
' For index_ = 0 to numberOfBrowsers_ - 1
' Browser("index:=0").Close
' Next
Reporter.Filter = rfEnableAll
End Sub


'
'08/04/2006 Jun Code Clean up: An assumption here is this sub is not called by a user script. Called only by action functions such as Click_Link and Set_ComboBoxItem_ByDataName, etc.
' Another assumption is this sub just waits a current page gets loaded set in hWindow variable, therefore hWindow have to be set previously.
'08/06/2006 Jun: Reverted the function due to a "working too fast" problem.
' I have found a problem that the test scripts can not always catch a right window's handle because it is too fast.
' Click_Link has to wait until a window is comletely loaded using sync_page, but sync_page doesn't know which window it has to observe until readState = "complete".

Sub Sync_Page

Dim CHECK_FREQUENCY_
CHECK_FREQUENCY_ = 0.5 'second how often this function verify if the page is loaded

Dim counter
counter = 0

'This is needed when a link in the second or the third popup page is clicked (or whatever acted) because the action might causes to refresh the main window.
If wHandle2 > 0 Or wHandle3 > 0 Then

Reporter.Filter = rfDisableAll
Do Until Browser("hwnd:=" & wHandle1).Page("title:=.*").Object.readyState = "complete" 'sync on main window
counter = counter + 1

'Time out
If (URL_FLAG = "CORE" and (counter * CHECK_FREQUENCY_) >= CORE_UI_MAX_SYNC_TIME) _
Or (URL_FLAG <> "CORE" and (counter * CHECK_FREQUENCY_) >= PMBI_MAX_SYNC_TIME) _
Then '
Call REPORT_FAILURE2("Sync_Page: sync aborted", "Waited for " & counter * CHECK_FREQUENCY_ & " seconds and still the page does not get loaded.")
Exit Do
End If

Call Wait (CHECK_FREQUENCY_)

Loop
Call Initiate_wHandle ' Why do I need to initialize handle? -- because I need to work with cases when window gets closed (second or third window)
Call Initiate_wHandle ' Need to call twice because Initiate_wHandle function has a bug.
End if

' this is for the current window
Reporter.Filter = rfDisableAll
counter = 0
Do Until Browser("hwnd:=" & hWindow).Page("title:=.*").Object.readyState = "complete"
counter = counter + 1

'Time out
If (URL_FLAG = "CORE" and (counter * CHECK_FREQUENCY_) >= CORE_UI_MAX_SYNC_TIME) _
Or (URL_FLAG <> "CORE" and (counter * CHECK_FREQUENCY_) >= PMBI_MAX_SYNC_TIME) _
Then
Call REPORT_FAILURE2("Sync_Page: sync aborted", "Waited for " & counter * CHECK_FREQUENCY_ & " seconds and still the page does not get loaded.")
Exit Do
End If

Call Wait (CHECK_FREQUENCY_)

Loop

End Sub

' Max, 12/01/04: This function is to handle windows. It works,
' After script has opened new popup (or closed existing popup), use this function to set proper window.
' Function takes three values: 1, 2, and 3, which represent how many browser windows are open when this funciton is called.
'
' JUN NOTE: QTP recognizes the active (most front) window as index=0 regardless of when it is opened.
' Therefore it needs a special technique to identify windows
Function Set_Window (idx)' valid values for IDX are: 1, 2, and 3.
Call wait(1)

Select Case idx
Case 1 ' the first window are targed
If (wHandle1 = 0) Then ' value for wHandle1 never changes
Reporter.Filter = rfDisableAll
wHandle1 = Browser("index:=0").GetROProperty("hwnd")
End if
wHandle2 = 0 'destroy value for 2nd window handle <----- IMPORTANT! This puts conditions on how user can switch between windows!!!
wHandle3 = 0 'destroy value for 3rd window handle
hWindow = wHandle1

Case 2 ' The second window is targeted
If (wHandle2 = 0) Then ' value for wHandle2 never changes, unless it has been reset above
'Assuming that the second window is active.
Reporter.Filter = rfDisableAll
wHandle2 = Browser("index:=0").GetROProperty("hwnd")

'Here is the technique
If wHandle2 = wHandle1 Then
'This is a case that the second window is opened but the first one is still active
wHandle2 = Browser("index:=1").GetROProperty("hwnd") ' only two windows open, so only two options are available to pick from
End If
End If

wHandle3 = 0 'destroy value for 3rd window handle
hWindow = wHandle2

Case 3 ' the third window are targed
'Assuming that the third window is active.
Reporter.Filter = rfDisableAll
wHandle3 = Browser("index:=0").GetROProperty("hwnd")

If (wHandle3 = wHandle1) or (wHandle3 = wHandle2) Then
'This is a case that the third window is opened but the first or second one is still active
If Browser("index:=2").GetROProperty("hwnd") <> wHandle1 And Browser("index:=2").GetROProperty("hwnd") <> wHandle2 Then
wHandle3 = Browser("index:=2").GetROProperty("hwnd")
ElseIf Browser("index:=1").GetROProperty("hwnd") <> wHandle1 And Browser("index:=1").GetROProperty("hwnd") <> wHandle2 Then
wHandle3 = Browser("index:=1").GetROProperty("hwnd")
End If
End If

hWindow = wHandle3

Case Else
Call REPORT_FAILURE_NO_IMAGE("Set_Window index(" & idx & ") Not Supported", _
"Set_Window index(" & idx & ") Not Supported")
Exit Function
End Select

Call Sync_Page
call CaptureWindowImage("Set_Window("&idx&"), hWindow = " & hWindow & ".")
End Function

' Max, 12/01/04: this function is used from inside of other functions in webBrowser.vbs. It helps to run scripts from any point, since it automatically will
' create handle for browser, something that is missing otherwise.
Function Initiate_wHandle()
Reporter.Filter = rfDisableAll ' 03/24/05, Max: this should help a lot since it will hide errors while initalizing handle
If hWindow = 0 Then
If wHandle1 = 0 Then
If Browser("index:=0").Exist(EXIST_TIME_OUT) Then
wHandle1 = Browser("index:=0").GetROProperty("hwnd")
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micFail, "NO WINDOWS OPEN!!!", ""
End If
else
if wHandle2 = 0 and Browser("index:=1").Exist(1) then
If wHandle1 = 0 Then
wHandle1 = Browser("index:=0").GetROProperty("hwnd")
end if
wHandle2 = Browser("index:=1").GetROProperty("hwnd")
Reporter.Filter = rfEnableAll ' 03/24/05, Max: this should help a lot since it will hide errors while initalizing handle
exit function ' is this correct?
end if
if wHandle3 = 0 and Browser("index:=2").Exist(1) then
If wHandle1 = 0 Then
wHandle1 = Browser("index:=0").GetROProperty("hwnd")
end if
If wHandle2 = 0 Then
wHandle2 = Browser("index:=1").GetROProperty("hwnd")
end if
wHandle3 = Browser("index:=2").GetROProperty("hwnd")
end if
End If
hWindow = wHandle1
Reporter.Filter = rfEnableAll ' 03/24/05, Max: this should help a lot since it will hide errors while initalizing handle
exit function ' is this correct? or should i check if there are more windows?
else
if Not Browser("hwnd:=" & hWindow).Exist(1) then ' this means second or third window got closed
if hWindow = wHandle3 then ' third window got closed
hWindow = wHandle2
wHandle3 = 0
else
if hWindow = wHandle2 then ' second window got closed
hWindow = wHandle1
wHandle2 = 0
end if
end if
end if
End If
Reporter.Filter = rfEnableAll ' 03/24/05, Max: this should help a lot since it will hide errors while initalizing handle
End Function

'FIX_ME *************************
Function Count_Browsers()
Count_Browsers = Count_Processes(BROWSER_EXE)
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micWarning, "Count_Browsers", "Unsupported function has been used by test case scripts"
End Function
'FIX_ME *************************

Function Window_Exists(pIntWindowHandler)
Window_Exists = Browser("hwnd:=" & pIntWindowHandler).Exist(WINDOW_EXIST_TIME_OUT)
End Function

''RETURNS
'' an array of strings
'Function sss(pStrText, pStrBoundaryText)
' Dim regEx, Match, Matches ' Create variable.
' Dim actualText_
' Dim returnTexts_()
' Dim returnTextsBuffer_()
' Dim returnTextsIndex_
'
' Set regEx = New RegExp ' Create a regular expression.
' regEx.Pattern = ".*" & pStrBoundaryText & "|" & pStrBoundaryText & ".*" & pStrBoundaryText & "|" & pStrBoundaryText & ".*" ' Set pattern.
' regEx.IgnoreCase = False ' Set case sensitivity.
' regEx.Global = True ' Set global applicability.
' Set Matches = regEx.Execute(pStrText) ' Execute search.
' returnTextsIndex_ = 0
' For Each Match in Matches ' Iterate Matches collection.
' Redim returnTextsBuffer_(returnTextsIndex_)
' If returnTextsIndex_ <> 0 Then
' returnTextsBuffer_ = returnTexts_
' End If
' Redim returnTexts_(returnTextsIndex_)
' If returnTextsIndex_ <> 0 Then
' returnTexts_ = returnTextsBuffer_
' End If
' returnTexts_(returnTextsIndex_) = Replace(Match.Value, pStrBoundaryText, "", 1, -1, vbTextCompare)
' returnTextsIndex_ = returnTextsIndex_ + 1
' Next
'
' sss = returnTexts_
'
'End Function

'=====Below functions were added by Venkat and submitted by Ariff

Function Click_Link_Verify_AccordingText_Exists(pStrLinkText, pIntLinkIndex,pStrContext, pIntContextIndex)

Call Click_Link(pStrLinkText, pIntLinkIndex)

If Text_Exists (pStrContext, pIntContextIndex) Then
Reporter.Filter = rfEnableAll
Call Reporter.ReportEvent(micPass, _
"Click_Link_Verify_AccordingText_Exists" , _
"the context('" & pStrContext & "') has been found")
Click_Link_Verify_AccordingText_Exists = PASS
Else
Call REPORT_FAILURE2("Click_Link_Verify_AccordingText_Exists" , _
"the context('" & pStrContext & "') was not found")
Click_Link_Verify_AccordingText_Exists = FAIL
End If
End Function

Function Verify_Table_Cell_Value_Exist_By_Row_Col_Ref(text,index,Row_Ref,Row_ref_col_index,Column_ref,Col_Ref_row_index,value_to_find)
Dim row_number, column_number, Value_current
row_number = GetRowIndex_AccordingValue_InTable(text,index,Row_ref_col_index,Row_Ref,0)
column_number = GetColumnIndex_AccordingValue_InTable(text,index,Col_Ref_row_index,Column_ref,0)
'msgbox "row_number = " & row_number & "Col Number : " & column_number
If row_number > 0 and column_number > 0 then
Value_current = Get_WebTable_Cell(text, index, row_number, column_number)
If Trim(Value_current) = Trim(value_to_find) then
Call REPORT_PASS("Verify_Table_Cell_Value_Exist_By_Row_Col_Ref", "Cell Value is correct; Table Name = '" & text & "' Row Ref : '" & Row_Ref & "' Column Ref : '" & Column_ref & "'")
Verify_Table_Cell_Value_Exist_By_Row_Col_Ref = PASS
Else
Call REPORT_FAILURE2("Verify_Table_Cell_Value_Exist_By_Row_Col_Ref", _
"Cell Value is not correct; Table Name = '" & text & "' Row Ref : '" & Row_Ref & "' Column Ref : '" & Column_ref & "' and WebTable_CellValue shown is '" & Value_current & "', NOT '" & value_to_find & "'.")
Verify_Table_Cell_Value_Exist_By_Row_Col_Ref = FAIL
End if
Else
Call REPORT_FAILURE2("Verify_Table_Cell_Value_Exist_By_Row_Col_Ref", _
"Row ref or Col ref not found; Table Name = '" & text & "' Row Ref : '" & Row_Ref & "' Column Ref : '" & Column_ref & "'")
Verify_Table_Cell_Value_Exist_By_Row_Col_Ref = FAIL
End if
End Function

Function GetColumnIndex_AccordingValue_InTable(text, index, row_number, value_to_find, diff)
Dim temp_diff, i, column_count, value_current
Call FUNCTION_START("GetColumnIndex_AccordingValue_InTable")
If diff<>0 Then
temp_diff = diff
else
temp_diff = 0
End If
column_count = Get_WebTable_ColumnCount(text, index)
Reporter.Filter = rfDisableAll
Table_Verify = FALSE
For i=1 To column_count
value_current = Get_WebTable_Cell(text, index, row_number,i)
If Trim(value_current) = Trim(value_to_find) Then
GetColumnIndex_AccordingValue_InTable = i + temp_diff
Call FUNCTION_END("GetColumnIndex_AccordingValue_InTable")
Reporter.Filter = rfEnableAll
Exit Function
End If
Next
GetColumnIndex_AccordingValue_InTable = -99 ' fail to find value in the table
Call REPORT_FAILURE("Failed to locate column number - probably text is not in the table?.. row number is invalid?...")
Call FUNCTION_END("GetColumnIndex_AccordingValue_InTable")
Reporter.Filter = rfEnableAll
Table_Verify = TRUE
End Function

Function Win_StaticText_Exists(pStrName, pIntIndex)
Call Initiate_wHandle ' make sure hWindow is known
Reporter.Filter = rfDisableAll
Win_StaticText_Exists = Browser("hwnd:=" & hWindow).Dialog("title:=" & BROWSER_NAME).Static("text:=" & pStrName , "index:=" & pIntIndex).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Verify_Win_StaticText_Exists(pStrName, pIntIndex) ' open issue: pIntIndex IS required...
If Win_StaticText_Exists (pStrName, pIntIndex) Then
Call REPORT_MSG2("Verify_Win_StaticText_Exists " & pStrName & " Found", _
"Verify_Win_StaticText_Exists " & pStrName & " Found")
Reporter.ReportEvent micPass, "Static text found: " & pStrName ,"."
Verify_Win_StaticText_Exists = PASS
Else
Call REPORT_FAILURE2("Verify_Win_StaticText_Exists " & pStrName & " Not Found", _
"Verify_Win_StaticText_Exists " & pStrName & " Not Found")
Verify_Win_StaticText_Exists = FAIL
End If
End Function


Function IFrame_WebElement_Exists(text)
Call Initiate_wHandle ' make sure hWindow is known
IFrame_WebElement_Exists = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).Frame("name:=~messageIFrame").WebElement("innertext:=" & text).Exist(OBJECT_EXIST_TIME_OUT)
End Function

Function IFrame_Verify_WebElement_Exists(text)
If IFrame_WebElement_Exists(text) then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"IFrame_Verify_WebElement_Exists", _
"WebElement found: WebElement = '" & text & "'"
IFrame_Verify_WebElement_Exists = PASS
else
Call REPORT_FAILURE2("IFrame_Verify_WebElement_Exists", _
"WebElement not found: WebElement = '" & text & "'")
IFrame_Verify_WebElement_Exists = FAIL
end if
End Function

Function IFrame_Verify_WebElement_NotFound(text)
If IFrame_WebElement_Exists(text) then
Call REPORT_FAILURE2("IFrame_Verify_WebElement_NotFound", _
"WebElement found: WebElement = '" & text & "'")
IFrame_Verify_WebElement_NotFound = FAIL
else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"IFrame_Verify_WebElement_NotFound", _
"WebElement not found: WebElement = '" & text & "'"
IFrame_Verify_WebElement_NotFound = PASS
end if
End Function

' ********************************************************************
' Function to click Edit Links on all profile screens.........Venkat


Function Click_Link_By_Table_Row_Column_Ref(text, index, row, col,LinkName)
Dim WebLinkObj,actualValue
actualValue = Get_WebTable_Cell(text, index, row, col)
If Trim(actualValue) = Trim(LinkName) then
Set WebLinkObj =Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & text & ".*","Index:=" & index).ChildItem(row, col, "Link", 0)
WebLinkObj.Click
Sync_Page
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass , _
"Click_Link_By_Table_Row_Column_Ref", _
"WebTable link click Pass : Link name = '" & LinkName & "'"
Click_Link_By_Table_Row_Column_Ref = PASS
else
Call REPORT_FAILURE2("Click_Link_By_Table_Row_Column_Ref", _
"WebTable link name shown is : '" & actualValue & "', NOT '" & LinkName & "'.")
Click_Link_By_Table_Row_Column_Ref = FAIL
End If
End Function

'Created by Jun
'This function assumes that in a particular cell, there is only one link.
' You specify a row and a col, then the function click the link in the particular cell.
Function Click_Link_In_Particular_Cell(pStrTableName, pIntTableIndex, row, col)
If Not WebTable_Cell_Exsists(pStrTableName, pIntTableIndex, row, col) Then
Call REPORT_FAILURE2("Click_Link_In_Particular_Cell: Cell Not Found", _
"Web Table cell(" & row & "," & col & ") Not Found in '" & pStrTableName & "', '" & pIntTableIndex & "'")
Click_Link_In_Particular_Cell = FAIL
Exit Function
End If

Dim WebLinkObj
Set WebLinkObj = Browser("hwnd:=" & hWindow).Page("title:=" & page_title).WebTable("text:=" & pStrTableName & ".*","Index:=" & pIntTableIndex).ChildItem(row, col, "Link", 0)
WebLinkObj.Click
Sync_Page
Call REPORT_MSG2("Click_Link_In_Particular_Cell: Link '" & WebLinkObj.GetROProperty("name") & "' clicked", _
"Clicked ' " & WebLinkObj.GetROProperty("name") & "' Link in cell(" & row & ", " & col & ") '" & pStrTableName & ", " & pIntTableIndex & "' table.")

Click_Link_In_Particular_Cell = PASS

Set WebLinkObj = Nothing

End Function 'End Of Click_Link_In_Particular_Cell

'========================================================================================
' GetRowIndex_ByValueAndValueIndex returns the row of the search value in a table. If value is not found, -99 will be returned.
'
Function GetRowIndex_ByValueAndValueIndex(StrTableName, StrTableIndex, StrSearchInColumnNum, StrSearchValue, StrSearchValueIndex)
Dim row_number, i, row_count, value_current, temp_val, counter
Call FUNCTION_START("GetRowIndex_ByValueAndValueIndex")

'Get the total of the row in the table.
row_count = Get_WebTable_RowCount(StrTableName, StrTableIndex)
Reporter.Filter = rfDisableAll

temp_val = Table_Verify
Table_Verify = FALSE

counter = 0
For i=1 To row_count
value_current = Get_WebTable_Cell(StrTableName, StrTableIndex, i, StrSearchInColumnNum)

If Trim(value_current) = Trim(StrSearchValue) Then
If counter = StrSearchValueIndex then
GetRowIndex_ByValueAndValueIndex = i
Reporter.Filter = rfEnableAll
Call FUNCTION_END("GetRowIndex_ByValueAndValueIndex, PASS")
Exit Function
Else
counter = counter + 1
end if

End If
Next
Reporter.Filter = rfEnableAll
GetRowIndex_ByValueAndValueIndex = -99 ' fail to find value in the table
Call REPORT_FAILURE("Failed to locate row number - probably text is not in the table?.. Column number is invalid?...")

Call REPORT_FAILURE("Failed to find '" & StrSearchValue & "' with index " & StrSearchValueIndex & _
" in Table '" & StrTableName & "' with table index " & StrTableIndex & ". The search is done in column " & StrSearchInColumnNum)
Call FUNCTION_END("GetRowIndex_ByValueAndValueIndex, FAIL")
Table_Verify = temp_val
End Function 'GetRowIndex_ByValueAndValueIndex

'-----------------------------
' 06/14/07, Max: Very usefull functions that compliment WinButton functions nicely
Function Dialog_Exists
Call Initiate_wHandle ' make sure hWindow is known '06/14/07, Max: Do we need this for Dialog? - Not sure.....
Reporter.Filter = rfDisableAll
Dialog_Exists = Browser("hwnd:=" & hWindow).Dialog("title:=" & BROWSER_NAME).Exist(OBJECT_EXIST_TIME_OUT)
Reporter.Filter = rfEnableAll
End Function

Function Verify_Dialog_Exists
If Dialog_Exists Then
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Dialog window found", "Dialog window found"
Verify_Dialog_Exists = PASS
Else
Call REPORT_FAILURE2("Function Verify_Dialog_Exists", "Dialog window not found")
Verify_Dialog_Exists = FAIL
End If
End Function

Function Verify_Dialog_NotFound
If Dialog_Exists Then
Reporter.Filter = rfEnableAll
Call REPORT_FAILURE2("Function Verify_Dialog_NotFound", "Dialog window found")
Verify_Dialog_NotFound = FAIL
Else
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micPass, "Dialog window not found", "Dialog window not found"
Verify_Dialog_NotFound = PASS
End If
End Function
'-----------------------------





'End Of This File

No comments: