cancel
Showing results for 
Search instead for 
Did you mean: 

Python external libraries and when any external methods are called, TC falls into infinite loop

SOLVED
Highlighted
Contributor

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"))

 

 

 

-Rajesh V V
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Re: Python external libraries and when any external methods are called, TC falls into infinite loop

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

-Rajesh V V

View solution in original post

3 REPLIES 3
Highlighted
Staff

Re: Python external libraries and when any external methods are called, TC falls into infinite loop

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"))

 

  image.png

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.

Best,
Justin Kim
Highlighted
Contributor

Re: Python external libraries and when any external methods are called, TC falls into infinite loop

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

-Rajesh V V

View solution in original post

Highlighted
Community Manager

Re: Python external libraries and when any external methods are called, TC falls into infinite loop

@RajeshVV Thank you so much for sharing!


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!

Retrieve Data from a Web Page

Participate!
Top Kudoed Authors