Reading the Test-Case and Test-Data from Excel Using Python
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reading the Test-Case and Test-Data from Excel Using Python
Hii All
My Aim is to Read the Execution Col if its Yes then it need to Take the values of that particular row and call those functions :
Now for the first when am Trying to Read data from excel I have coded this from the Test-Complete Article
RecNo = 0 # Posts data to the log (helper routine) def ProcessData(): global RecNo Fldr = Log.CreateFolder("Record: " + aqConvert.VarToStr(RecNo)) Log.PushLogFolder(Fldr) for i in range(DDT.CurrentDriver.ColumnCount): Log.Message(DDT.CurrentDriver.ColumnName[i] + ": " + aqConvert.VarToStr(DDT.CurrentDriver.Value[i])) Log.PopLogFolder() RecNo = RecNo + 1 # Creates the driver (main routine) def TestDriver(): # Creates the driver # If you connect to an Excel 2007 sheet, use the following method call: Driver = DDT.ExcelDriver("C:\\DriverSheet.xls", "TestStep",True) # Iterates through records while not Driver.EOF(): ProcessData(); # Processes data Driver.Next(); # Goes to the next record # Closes the driver DDT.CloseDriver(Driver.Name);
But the OutPut of this Displaying as Record 1 Record 2 ....Record4 that's it .
Where did i went wrong or else do i need to add something else to the above code
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And i have Tried otherway to get the data but am facing the Python Run-time Error method cannot be callable
def ReadDataFromExcel(): xl = Sys.OleObject["Excel.Application"] book = xl.Workbooks.open("C:\\DriverSheet.xls") TCSheet = book.Worksheets("TestCases") #TCSheet = WorkBook.worksheets("TestCases") TSSteps = book.Worksheets("TestSteps") TCRows = TCSheet.UsedRange.Rows.Count for i in range(2,TCRows): if TCSheet.cells(i,2).Value == "Yes": SlNo = TCSheet.cells(i,1).Value Module = TCSheet.cells(i,2).Value TestCase = TCSheet.cells(i,3).Value Duration = 0 TSRows = TSSheet.UsedRange.Rows.Count for j in range (2,TSRows): if((TSSheet.cells(j,1).Value == TestCase) and ( TSSheet.cells(j,4).Value == "Yes")): Flag = Flag+1 if Flag ==1: Report.CreateTestCaseReportHeader(TestCase) TSCols = TSSheet.UsedRange.Columns.Count TSData = "" for k in range (5 , TSCols): TSData = TSData & TSSheet.cells(j,k).Value & ";" Parameter = Split(Tsdata,";") BeforeTime = aqDateTime.Time() Execute.TSSheet.cells(j,3).value AfterTime = aqDateTime.Time() Duration = Duration + aqDateTime.TimeInterval(AfterTime,BeforeTime)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The example is creating folders in the log file called Record: 0, Record: 1, etc.
Expand the folders to see the values.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@joseph_michaud thanks for the info which location it will create the folder and details.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no'plus' to the left of the line in the TestComplete Test Log.But when i checked in the Additional info it was showing the values , now i can read a single column value and based on that i need to read the entire row values stored in diff param's .Can you please help me out
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming your image somehow corresponds to your COM automation example, then the answer is to not concatenate your column values together:
for k in range (5 , TSCols): TSData = TSData & TSSheet.cells(j,k).Value & ";"
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @joseph_michaud for the COM automation am facing an python run-time error "the method is not callable " at the line which is in Red Font .
