Forum Discussion
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
Are you using the return option in your script as described here?
- jgoetz9 years agoOccasional Contributor
Yes, that is the line above "If Eval("KeywordTests." + testCaseName + ".Run") Then"
- djadhav9 years agoRegular Contributor
I don't see it in your example. Can you post the script that returns the value? e.g. body of globallogin script
- jgoetz9 years agoOccasional 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?
joseph_michaud 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.