Forum Discussion

jgoetz's avatar
jgoetz
Occasional Contributor
9 years ago

Last Operation Result returns blank

I have a master VBA script that loops through a spreadsheet header row to get the name of the keyword script that I want to run next, then feeds that name from the header as a variable to run that script.  I am now trying to get the result of that keyword test, pass, warning or fail, and write that back to the spreadsheet in the row below the header.  I know how to write back to the spreadsheet but what I have a problem with is getting a value for the result, it is always returning blank so it always goes to the else even though the keyword test passed.

 

I have tried the following that I found in other topics, but always blank.  Is there something I am missing?

 

LastResult = Eval("KeywordTests." + testCaseName + ".Run")

If (LastResult = True) Then

Call Log.Message("Pass", "")

Else

Call Log.Message("Fail", "")

End If

 

 

 

If Eval("KeywordTests." + testCaseName + ".Run") Then

Log.Message "Test returned True"

Else

Log.Message "Test returned False"

End If

 

I have also tried this through just a simple keyword test, but still returns blank. 

 

 2016-01-05_11-15-37.jpg

2016-01-05_11-17-52.jpg

 

12 Replies

  • djadhav's avatar
    djadhav
    Regular Contributor

    Could you post a couple of scripts that are supposed to return a value?

    • jgoetz's avatar
      jgoetz
      Occasional Contributor

      Here is ideally the script that I would use, but when it gets to the if Eval.... to get the results from running the script, the script runs, but it always goes to the else even though the script that was called passed. 

      Sub testSuiteRun(scriptRunType, customerType, runComponentArea)
        
        Dim excelApplication, projectPath
        Dim sheetName
        
        'Open and set Excel objects, spreadsheet, sheet, row count and column count
        Set excelApplication = Sys.OleObject("Excel.Application")
        projectPath = Project.Path
        Set book = excelApplication.Workbooks.Open(projectPath & "Test Data\TC_Script_Run.xlsx")
        sheetName = runComponentArea
        Set sheet = book.Sheets(sheetName)
        rowCount = sheet.UsedRange.Rows.Count
        colCount = sheet.UsedRange.Columns.Count  
        tcCount = 1
        
        excelApplication.DisplayAlerts = False
        'Loop through rows of spreadsheet ignoring the header row
        For r = 2 To rowCount
          
          'check if active row = run type and customer type 
          If (sheet.Cells(r, 1) = scriptRunType And sheet.Cells(r, 2) = customerType) Then
            
            'Loop through component script columns     
            For c = 4 To colCount
              
              'Set test case name to the header cell (row 1) for active column and the run indicator for active column and row
              testCaseName = VarToString(sheet.Cells(1, c)) 
              runInd = VarToString(sheet.Cells(r, c)) 
               
              'Check if test case name is not blank for active col to eliminate extra blank columns   
              If testCaseName <> "" Then
                
                'check if run indicator is Y and if so then call that component script   
                If runInd = "Y" Then
                                     
      		If Eval("KeywordTests." + testCaseName + ".Run") Then
      
      			sheet.Cells(r, c) = "P"
      
      		Else
      
      			sheet.Cells(r, c) = "F"
      
      		End If
                
                           
                  book.Save
                               
                End If
              
              End If
          
            Next
        
          End If
          
        Next
      
        'quit excel
        excelApplication.Quit
        excelApplication.DisplayAlerts = True
      
      End Sub

       

      I have also tried a very simple one like the following and what is returned to the log is blank.

      Sub Test_Run_JG()
        Dim Var1, LastResult
        Var1 = ""
         'Set LastResult = KeywordTests.Global_Login.Run
        LastResult = KeywordTests.Global_Login.Run
        Var1 = LastResult
        'Posts an information message to the test log.
        Call Log.Message(Var1, "")
      End Sub