Ask a Question

Last Operation Result returns blank

jgoetz
Occasional Contributor

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 12
djadhav
Regular Contributor

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

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
djadhav
Regular Contributor

Are you using the return option in your script as described here?

 

https://support.smartbear.com/viewarticle/70647/

jgoetz
Occasional Contributor

Yes, that is the line above "If Eval("KeywordTests." + testCaseName + ".Run") Then"

As djadhav asks:  'What value do the called tests return?"  Try logging the returned value in the called test.

-----
Joseph
djadhav
Regular Contributor

I don't see it in your example. Can you post the script that returns the value? e.g. body of globallogin script

jgoetz
Occasional Contributor

Maybe I don't understand exactly what both of you are asking, or I wasn't clear above but hopefully I can answer. 

 

djadhav  - In the testSuiteRun Sub code above, I included basically the code that is in the "Using the Return Operation" section in the link you included in your post.  It is represented in this code:

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

   sheet.Cells(r, c) = "P"

  Else

   sheet.Cells(r, c) = "F"

  End If

 

After it plays the script on the If Eval("KeywordTests." + testCaseName + ".Run") Then line, it jumps to the Else step. 

 

I don't know if that is what you mean by "Did you include the Return Option.." or not, or is there something else I need to do?  If so where would it fit into the testSuiteRun sub script above?

 

and djadhav - Above is also the script, Test_Run_JG(), that I did in fact try to log the return value, and it returns nothing, it is blank, no True or False, nothing. 

 

Here are screenshots again of just a keyword script that I had also tried before posting with calling another keyword script, then logging Last Operation Results.  Again, nothing.

2016-01-05_14-17-48.jpg

2016-01-05_14-18-54.jpg

djadhav
Regular Contributor

I apologize if I was not very clear. That code would not go in the testSuiteRun.

 

Here is an example of what I am asking:

 

Your code Eval("KeywordTests." + testCaseName + ".Run") calls a piece of code referred to by the 'testCaseName'. That piece of code should have a return statement in the end.

 

e.g. Let's say testCaseName is Login from the Excel file. So you will call Eval("KeywordTests.Login.Run"). I need to see Login module that is being executed here because that is where the return statement would go.

 

Hope this helps

jgoetz
Occasional Contributor

Ok i don't see that mentioned in what I have read.  The script being called is a keyword test script, not a VBA script, it is looks like this.

2016-01-05_14-41-46.jpg

 

From what I read here, https://support.smartbear.com/viewarticle/74736/ the Last Operation Result should carry over to the script/keyword that it is called from without adding anything to the keyword that is called.  Or maybe I miss it. 

 

I would prefer not to have update all of the 50 some keyword tests that we already have being called if that is possible.

cancel
Showing results for 
Search instead for 
Did you mean: