yon-cuadrado
11/8/2019 - 7:10 PM

common-functions-not-tested.vbs



'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Function	fSearchValueInTable( objTable, strValue1, strColumn1,, strValue2, strColumn2,, strValue3, strColumn3)
'Descripcion: This function searchs a row in a table with several values
'
'Parameters: 
'objTable = table object where the values are going to be searched
'strValue1 = value of the first column that is going to be searched in the table
'intColumn1 = column number where the first value is going to be searched
'strValue2 = value of the second column that is going to be searched in the table
'intColumn2 = column number where the second value is going to be searched
'strValue3 = value of the third column that is going to be searched in the table
'intColumn3 = column number where the third value is going to be searched

'Return value
'the row number where the values are found or  valor no encontrado in case the value is not found
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function fSearchValueInTable( objTable, strValue1, intColumn1, strValue2, intColumn2, strValue3, intColumn3,  bolPaginar)

	fSearchValueInTable = "no encontrado el valor en la tabla"
	Set ObjTableLocal = objTable

	Do 

		bolPaginationButtonClick = False

		Browser("Browser").Page("Page").WebTable("status").RefreshObject
		intRowCount = ObjTableLocal.RowCount
		intRowIndex = 1

		Do

			If strValue1 <> "" Then
				strTableValue1 = ObjTableLocal.GetCellData(intRowIndex,intColumn1)
			End If

			If strValue2 <> "" Then
				strTableValue2 = ObjTableLocal.GetCellData(intRowIndex,intColumn2)
			End If

			If strValue3 <> "" Then
				strTableVaue3 = ObjTableLocal.GetCellData(intRowIndex,intColumn3)
			End If

			If Trim(strTableValue1) = Trim(strValue1) And Trim(strValue2) = "" And Trim(strValue3) = "" Then
				fSearchValueInTable = intRowIndex
				Exit Do
			ElseIf Trim(strTableValue1) = Trim(strValue1) And Trim(strValue2) = Trim(strTableValue2) And Trim(strValue3) = "" Then
				fSearchValueInTable = intRowIndex
				Exit Do
			ElseIf Trim(strTableValue1) = Trim(strValue1) And Trim(strValue2) = Trim(strTableValue2) And Trim(strValue3) = Trim(strTableValue3)  Then
				fSearchValueInTable = intRowIndex
				Exit Do
			End If

			intRowIndex = intRowIndex + 1

		Loop While intRowIndex <= intRowCount

		If fSearchValueInTable <> "no encontrado el valor en la tabla" Then
			Exit Do
		ElseIf Browser("Browser").Page("Page").WebElement("Next 10 >>").Exist(1) And bolPaginar = True Then
			Browser("Browser").Page("Page").WebElement("Next 10 >>").Click
			Browser("Browser").Page("Page").Sync
			bolPaginationButtonClick = True
		ElseIf bolPaginar = False Then
			Exit Do
		End If

	Loop While  bolPaginationButtonClick = True

End Function


'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Function	fClosePopupIEWindow()
'Descripcion: This function gets the list of all tthe ie windows
'
'Parameters: 
'strParametersTab = Name of the tab where the parameters are stored
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function fClosePopupIEWindow()

	fClosePopupIEWindow = "FAILED"
	Dim objShell 
	Dim objShellWind 
	Dim objIexplorer
	Dim objDocument 
	Dim x 

	Set objShell = CreateObject("Shell.Application")
	Set objShellWind = objShell.Windows
	Set objIexplorer = CreateObject("InternetExplorer.Application")
	strBrowserTitles = "Información|Info|Error|Buscar sociedad|Mantenimiento de perímetro|Advertencia|Los campos marcados de color azul son obligatorios.|Faltan datos de búsqueda.|Alerta|" & _ 
									    "The case with the associated dispute transactions will be created."
'	Workbooks.Add
	x = 1

	For Each objIexplorer In objShellWind

		On Error Resume Next
		Set objDocument = objIexplorer.Document

		If Err.Number <> 0 Then
			str1 = 1
		Else	

			If LCase(TypeName(objDocument)) = "htmldocument" Then
				browserURL = objDocument.URL
				browserTitle = objDocument.Title
				intLinks =  objDocument.Links.length

				If InStr(1,strBrowserTitles,browserTitle) <> 0 And browserTitle <> "" Then

					Set webelements = objDocument.getElementsByTagName("DIV")

					attributeIndex = 0
					intAttributesCount = webelements.length

					Do 

							strAttributeValue  = webelements(attributeIndex).innerhtml
							strText =  webelements(attributeIndex).innerText

									If InStr(1,strBrowserTitles,browserTitle) <> 0 And browserTitle <> "" And intLinks > 0  Then

										For Each lnk In objDocument.Links
											If lnk.value = "Ok" Then
												lnk.Click
												fClosePopupIEWindow = "PASSED"
												Exit Function
											End If
										Next

									End If

							attributeIndex = attributeIndex + 1
					Loop While attributeIndex <= intAttributesCount

					'objIexplorer.Quit
					Set objShell = Nothing
					Set objShell = Nothing
					Set objShellWind = Nothing
					Exit Function
				End If
				x = x + 1
			End If
		End If

	Next

	Set objShell = Nothing
	fClosePopupIEWindow = "PASSED"

End Function