Verifying data in Excel file
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Verifying data in Excel file
My tested application outputs the reports as excel files. These files have user and date information which does not lend them well to a file comparison. I'd like to be able to verify data contained in a range of rows and columns contained in selected sheets of the excel file.
This topic has been broached previously, and I believe Robert was on the right track in this post, however, it does not have enough detail for me. https://community.smartbear.com/t5/TestComplete-General-Discussions/How-to-test-the-content-of-an-Ex...
I am able to use the following script routine to get the data from select sheets of my outputted excel file. Can I now use this information that is contained in the Test Log to compare to baseline values? How is that done? How can I specify the rows and columns?
var RecNo;
// Posts data to the log (helper routine)
function ProcessData()
{
var Fldr, i;
Fldr = Log.CreateFolder("Record: " + aqConvert.VarToStr(RecNo));
Log.PushLogFolder(Fldr);
for(i = 0; i < DDT.CurrentDriver.ColumnCount; i++)
Log.Message(DDT.CurrentDriver.ColumnName(i) + ": " + aqConvert.VarToStr(DDT.CurrentDriver.Value(i)));
Log.PopLogFolder();
RecNo = RecNo + 1;
}
// Creates the driver (main routine)
function TestDriver()
{
var Driver;
// Creates the driver
// If you connect to an Excel 2007 sheet, use the following method call:
// Driver = DDT.ExcelDriver("C:\\MyFile.xlsx", "Sheet1", true);
Driver = DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1");
// Iterates through records
RecNo = 0;
while (! Driver.EOF() )
{
ProcessData(); // Processes data
Driver.Next(); // Goes to the next record
}
// Closes the driver
DDT.CloseDriver(Driver.Name);
}
It seems that this is where the data driven loop comes in, but I don't know how to make use of that to confirm values.
Apologies if this is a duplicate post in some way. I tried to post this question previously but was not able to find record of it, so I am posting again.
Thanks,
Mike
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feel so close, but I get another Unexpected token for the ">" in the if statement. I really need to learn some coding.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Replace "<>" with "!="
I used a variaty of different coding languages in my day to day so sometimes get the syntax mixed up. Both of those combinations of symbols represent "not equal to" but for different scripting languages.
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since you appear to be using some form of JavaScript, I can recommend
https://www.w3schools.com/js/default.asp
As well as
I know, also, that @LinoTadros did a "Scripting for TestComplete" course somewhere as well. I can't find it at the moment but you might be able to search for that.
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Robert - thanks for the input. I am going to mess around with this now and see if what I can do with selecting the starting point. I assume that is the RecNo =.
In case anyone comes across this with as little coding experience as I have this is the final version. Which contains the updates to editorial and bracketing errors.
function TestDriver()
{
var Driver;
// Creates the driver
// If you connect to an Excel 2007 sheet, use the following method call:
// Driver = DDT.ExcelDriver("C:\\MyFile.xlsx", "Sheet1", true);
TestDriver = DDT.ExcelDriver("C:\\Users\\mmau\\Downloads\\ControlAreaList.xlsx", "CA 1-1 (1)");
BaseDriver = DDT.ExcelDriver("C:\\Users\\mmau\\Downloads\\ControlAreaListBaseline4.6HazAnalysis.xlsx", "CA 1-1 (1)")
// Iterates through records
RecNo = 0;
while (!TestDriver.EOF() && !BaseDriver.EOF())
{
for (var i = 0; i < TestDriver.ColumnCount; i++) {
if (TestDriver.Value(i) != BaseDriver.Value(i)) {
Log.Warning("Test file column " + TestDriver.ColumnName(i) + " does not match baseline")
}
}
TestDriver.Next(); // Goes to the next record
BaseDriver.Next();
}
// Closes the driver
DDT.CloseDriver(TestDriver.Name);
DDT.CloseDriver(BaseDriver.Name);
}

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »