cancel
Showing results for 
Search instead for 
Did you mean: 

Test result status not refreshing

SOLVED
Highlighted
Community Hero

Re: Test result status not refreshing

The error appears to be happening when trying to access app.Cells.  I'm guessing that there's an issue in accessing Excel.  Make sure that the Excel spreadsheet is actually closed and Excel is not running in the background.  

Also, as @shankar_r, make sure we actually have data in the array.  


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Contributor

Re: Test result status not refreshing

I will give this a try when i get home from work

 

Many Thanks for your reply

Highlighted
Contributor

Re: Test result status not refreshing

I debugged the array and it populates with the correct data and then when it enters the 'for' loop it gives a run time error and states a  " ; " was expected. Ive tried to change the syntax however it still falls over.

 

I also closed Excel down from the Task Manager - Error still happens

Highlighted
Community Hero

Re: Test result status not refreshing

Can you paste here the actual script functoin which is causing issue?


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

Highlighted
Contributor

Re: Test result status not refreshing

It was the reply I had from tristaanogre - but I can't seem to get it working at all.


function WriteDataToExcel(fname, sheetName,testTime, errorCount, warnCount){

var app = Sys.OleObject("Excel.Application");
var book = app.Workbooks.Open(fname);
var sheet = book.Sheets.Item(sheetName);
var rowCount = sheet.UsedRange.Rows.Count+1;
var columnCount = sheet.UsedRange.Columns.Count;

var Logs;
var Count;

// Obtains the object that holds the list of project logs
Logs = Project.Logs;
Count = Logs.LogItemsCount;
var TestResult = Logs.LogItem(Count-1).Status;

switch (Status) {
case 0:
TestResult = "Passed"
break;

case 1:
TestResult = "Warnings"
break;

case 2:
TestResult = "Failed"
break;

default :
TestResult = "Error"
break;
}


var arrayLogData = [aqConvert.DateTimeToFormatStr(aqDateTime.Now(), "%d/%m/%y %H:%M"),
Logs.LogItem(Count-1).Name,
TestResult,
testTime,
errorCount,
warnCount]
// When you need to add additional data, just add the new element here

for (i = 0; i < columnCount; i++) {
app.Cells(rowCount, i) = arrayLogData[i]; //This then maps your array of data to yhour column count and sets the values
}
book.Save();
app.Quit();
}
Community Hero

Re: Test result status not refreshing

So, I have changed some of the lines which are highlighted and added function to get properly enter the data into excel sheet.

function WriteDataToExcel(fname, sheetName,testTime, errorCount, warnCount){

var app = Sys.OleObject("Excel.Application");
var book = app.Workbooks.Open(fname);
var sheet = book.Sheets.Item(sheetName);
var rowCount = sheet.UsedRange.Rows.Count+1;
var columnCount = sheet.UsedRange.Columns.Count;

var Logs;
var Count;

// Obtains the object that holds the list of project logs
Logs = Project.Logs;
Count = Logs.LogItemsCount;
var TestResult = Logs.LogItem(Count-1).Status;

switch (TestResult) //previously it is like Status which is undefined
{ case 0: TestResult = "Passed" break; case 1: TestResult = "Warnings" break; case 2: TestResult = "Failed" break; default : TestResult = "Error" break; } var arrayLogData = [aqConvert.DateTimeToFormatStr(aqDateTime.Now(), "%d/%m/%y %H:%M"), Logs.LogItem(Count-1).Name, TestResult, testTime, errorCount, warnCount] // When you need to add additional data, just add the new element here sheet.Range("A" + rowCount).Value = alignData(arrayLogData[0]); sheet.Range("B" + rowCount).Value = alignData(arrayLogData[1]); sheet.Range("C" + rowCount).Value = alignData(arrayLogData[2]); sheet.Range("D" + rowCount).Value = alignData(arrayLogData[3]); sheet.Range("E" + rowCount).Value = alignData(arrayLogData[4]); sheet.Range("F" + rowCount).Value = alignData(arrayLogData[5]); // If you want add more columns then you can add like below //sheet.Range("G" + inputRow).Value = alignData(arrayLogData[6]); book.Save(); app.Quit(); } function alignData(datatoEnter) { try { var tempValue = aqConvert.VarToStr(datatoEnter); if(tempValue != "") { return tempValue; } else { return ""; } } catch(ex) { return "ERROR FIELD"; } }

Let me know your results.


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

View solution in original post

Highlighted
Contributor

Re: Test result status not refreshing

Thanks again for your reply.

 

This worked brilliantly and will make it easy for me to add records in the future- Many thanks

Highlighted
Community Hero

Re: Test result status not refreshing

Thanks for the correction, @shankar_r... as mentioned, mine was probably not the best solution. 🙂  And totally messed up the switch statement... that was just a dumb copy/paste error.

Glad things are working @Vec84!


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Community Hero

Re: Test result status not refreshing

You are welcome @tristaanogre. Error may come like 1 out of 1000 🙂  is your case. Smiley Tongue


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

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

Changing options from outside of TestComplete

Participate!

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!
Top Kudoed Authors