Forum Discussion

Stereo5677's avatar
Stereo5677
Occasional Contributor
2 years ago
Solved

Is there a way to store a global or project property inside a virtualized service response script?

I have a virtualized service that is running a script for it's response. Is there a way that I can store properties in that script so that they would be accessible inside groovy scripts inside the testing portion of the project instead of the virtualization portion? The issue I was running into was that testRunner is not accessible there. Normally that is what I would use to save properties.

9 Replies

  • hey, i took your code and then ran it, it seems to work on my end when i run the testexcel() function.

     

    from os import sys
    sys.path.insert(0, 'C:\\Users\\justin.kim\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages')
    import openpyxl
    
    def ExcelReadSingleCell(Sheet,Cell):
      excelPath = "C:\\Users\\justin.kim\\Desktop\\test.xlsx"
      wb = openpyxl.load_workbook(excelPath )
      ws = wb.get_sheet_by_name(Sheet)
      mycell=ws[Cell]
      return str(mycell.value)
    
      
      
      
    def testExcel():
      Log.Message(ExcelReadSingleCell("Sheet1", "D3"))
      Log.Message(ExcelReadSingleCell("Sheet1", "D4"))
      Log.Message(ExcelReadSingleCell("Sheet1", "D5"))
      Log.Message(ExcelReadSingleCell("Sheet1", "C3"))
      Log.Message(ExcelReadSingleCell("Sheet1", "C5"))

     

      

    I'd suggest filing for a support ticket, and the support engineers will guide you through using probably the report generator utility to take a look at your system and see if they can identify what the problem is with TestComplete when you are running your system. With that said, I have personally experience some problems too when using external libraries, like random closing of testcomplete. So to achieve this goal right now, I'd suggest looking into using the Sys.OleObject["Excel.Application"] object to interact with your spreadsheets.