Forum Discussion
- JavierCollRodriContributorHi Anil,
As long as I know, there is no 'one click' way to export the results to a excel from the log generated by Test Complete.
What you can do is a function that everytime a message is posted in TestComplete log, to write it down in an excel sheet. For example:
function LogMessage(text, excelRow, excelColumn)
{
Log.Message(text);
// Write to excel
return new Array(newRow, newColumn);
}
This function should post a message to the Log, and then write it to the excel file you wish. There are some issues that you will have to solve:
Keep the excel opened all the execution? Or open it and close it everytime? (You can execute Excel without beeing visible, so it won't bother in screen)
You have to keep track over the rows and columns, so you won't write over the same cell all the time.
You will need to change the script if you want to post messages, warnings, errors... Or create othe functions.
What about pictures?
You can use the earlier links to know how to write on excel.
In my case, what I do is keep an array with everyline of text I want to write on excel (text + message type), and when I finish on a test set, I write them down in the excel file. What I do with pictures is save them in a shared folder and put a link in the excel file, so it won't grow up like a monster.
I hope it helped! - JeniferantoOccasional ContributorHi Javier Coll ,
Can you please tell how to hyperlink the file that I am writing back to the excel file.
I am capturing screen shots and saving it in file. I am writing the filepath back to excel file. But I am not able to create a hyperlink to that path.
Can you please help me with it.
Thanks
Jenifer. - TanyaYatskovskaSmartBear Alumni (Retired)
Hi Jenifer,
I've answered you in the TestComplete LinkedIn group. Here is the copy of my reply:
You can use the Hyperlinks.Add Method method - http://msdn.microsoft.com/en-us/library/office/ff822490.aspx
I have a sample that adds a hyperlink to a Word document - maybe it will help:
'VBScript
Sub Main
Dim strLink, oWord, oDoc, oRange, oHL
strLink = "http://www.smartbear.com"
Set oWord = Sys.OleObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add
Set oRange = oDoc.Range
Set oHL = oRange.Hyperlinks.Add(oRange, strLink, False, False, "Sample")
End Sub
- AlexKarasChampion Level 3> [...] some of the values (sentences, etc.) that I wrote to the log contained commas [...]
AFAIR, such strings should be quoted. Then they will be processed fine by the csv driver. Possible quotes within quoted values must be quoted as well, so I can recommend aqString.Quote() to handle this. - jeffrey_crowleyContributorYou are correct. In most cases, surrounding the values with quotes is enough to allow commas. I actually forgot about that step in my discovery process and so I didn't mention it in my post above. Some of the text I was processing already had quote marks (measurements, e.g. 2 1/2") so that messed up my plan so I ended up doing what I mentioned above.
So... a quick summary for those that come later...
If you don't have commas or quotes in your values, you can just separate all values with commas. e.g. value1,value2, value3
If you have commas (but not quotes) in your values, you can surround those strings with quotes. (This is probably just good practice anyway to avoid the oops later) e.g. "$1,200","$1,400","$1,600"
If you have quotes in your strings, pick a different separator value that will never show up in one of your values. e.g. 2 1/2"|3"|3 1/2" (where | is the separator)
If you don't have to use #3, you can save the text file with the CSV extension and Excel will open it as is. If you have to use #3 then you will have to use Excel's text import wizard to specify the separator value... it's not that hard but it's an extra step. I ended up writing a quick Excel macro to do the import for me. - AlexKarasChampion Level 3I would add:
-- If you have #2 but don't want to resort to custom separator, you may try aqString.Quote() which will quote the string and double quote every quote within the string (e.g [1 1/2"] will become "[1 1/2""]"). This should make it possible for the csv file to be imported into Excel without the necessity of any additional setting.
Note: I did not check explicitly the above, but this is what I seem to remember from the documentation. - jeffrey_crowleyContributor
Alexei,
I just tried aqString.Quote() and it's not working quite as you thought. According to the Quote Method page,
The Quote method returns the quoted version of the given string (InputString). This function inserts quotation marks at the beginning and at the end of the string. The quotation mark is specified by the QuoteSymbol property, its default value is a double quote ( " ).
So... all it does it add quotes at the start and end of a string. There is no mention of double quoting quotes inside the string.
I just tried this example:
Log.Message(aqString.Quote("1-1/2\", 2-2/3\""));
It returned "1-1/2", 2-2/3" instead of your expected "1-1/2"", 2-2/3"""
If I'm missing something, please correct me but I think I will stick with my alternate separator for now... :) - AlexKarasChampion Level 3Hi Jeff,
Indeed, aqString.Quote() works as you wrote (and I think this is a problem in certain cases like ours).
Utilities.QuotedStr() works as required, but it works with single quotes only.
Related Content
- 2 months ago
- 7 years ago
- 3 years ago
- 8 years ago
- 3 years ago
Recent Discussions
- 7 hours ago