Python external libraries and when any external methods are called, TC falls into infinite loop
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Python external libraries and when any external methods are called, TC falls into infinite loop
Hi,
I tried using OpenPyxl and then when I'm trying to run certain methods and for handling excel values.
This happens for very first time, and when we rerun the same script to run after the first successful result, TC doesn't execute and doesn't respond, have to kill it from task manager to run it again
Sample Script used is
def ExcelWriteSingleCell(Sheet,Cell,Value):
excelPath = "path"
wb = openpyxl.load_workbook(excelPath )
ws = wb.get_sheet_by_name(Sheet)
mycell=ws[Cell]
mycell.value = Value
running the above method once will result properly, whereas rerunning the same will result in infinite loop state or TC not responding state
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"))
Solved! Go to Solution.
- Labels:
-
Data-Driven Testing
-
Scripting
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Justin Kim
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the response,
whereas there's no issue with TC, it was happening due to Python library NumPy, which is been used in another unit of the suite, resolution provided by support team.
Further details related to issue can be found here
https://github.com/numpy/numpy/issues/8097
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@RajeshVV Thank you so much for sharing!
Sonya Mihaljova
Community and Education Specialist
