cancel
Showing results for 
Search instead for 
Did you mean: 

how to compare the items in the witemlist and the values passed in excel sgould be equal.

SOLVED
Contributor

how to compare the items in the witemlist and the values passed in excel sgould be equal.

we are running a regression with keyword driven framewrok and wanted to write a vb script code to compare list of values in the combobox  that are passed in the excel is matching the witemlist.

 

trim(uCASe(obj.witemlist)) = trim(ucase(value))

 

when i debug i see all the values are matching but only issue is the values passed in excel are showing continuously like x y z. even the value the cell column in excel

x

y

z

how to handle this?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: how to compare the items in the witemlist and the values passed in excel sgould be equal.

Actually, you know what, I'd do it in a series of checks... 

So, it's a dropdown/combo box.  I'm guessing Windows Desktop application.  So, first comparison is to compare the lengths.  If they don't match, don't bother.  Then, once we know the lenghts match, we just go down the line, item by item.

var excelList = 'x y z';
aqString.ListSeparator = ' ';
if (Aliases.MyApp.MyForm.MyComboBox.wItemCount)  != aqString.GetListLength(excelList)) {
   Log.Error('The list lengths don't match');
}
else {
    for (var i=0; i < aqString.GetListLength(excelList);i++){
       if (Aliases.MyApp.MyForm.MyComboBox.wItem(i) != GetListItem(excelList(i))){
            Log.Error('List item ' + i + ' does not match');
        }
    }
}

Robert Martin
[Community Expert Group]
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
Extensions available
6 REPLIES 6
Community Hero

Re: how to compare the items in the witemlist and the values passed in excel sgould be equal.

As noted, wItemList is a list with a separator character, most likely a CR character.  So, if you want to compare the two lists, you'll need to process wItemList to format it in the same formate as the Excel sheet... OR... format your excel sheet to match what is in wItemList.  You can use aqString.GetListLength, aqString.SeparatorCharacter, aqString.GetListItem, etc., to process the string of data in wItemList.


Robert Martin
[Community Expert Group]
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
Extensions available
Contributor

Re: how to compare the items in the witemlist and the values passed in excel sgould be equal.

In the excel after each list i gave ="X"&CHAR(10)&"Y"&CHAR(10)&"Y"

still it is not seeing the spaces. so to avoid the spaces in witemlist is there any method i can use. so it avoids the spaces between the each item when comparing.

Community Hero

Re: how to compare the items in the witemlist and the values passed in excel sgould be equal.

I already told you... you're going to have to manipulate the data in wItemList and/or what's in Excel in order to get them to match the data presentation.

There may be other properties as well... possibly an wItems property which is an indexed array that you can cycle through and build your own listing to match what's in excel.


Robert Martin
[Community Expert Group]
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
Extensions available
Contributor

Re: how to compare the items in the witemlist and the values passed in excel sgould be equal.

Hi Robert,

Is there any sample code that i can see.I tried looping with one item at a time and then comparing with the value coulmn in the excel. But x y z are all in one cell. I am not able to compare that way. Sample code might help me to understand.

Community Hero

Re: how to compare the items in the witemlist and the values passed in excel sgould be equal.

Let's take what you have in the Excel cell... you have the following

x y z

There is a character between these... the space character.  So, this is a list of items with the separator being the space.  Each item in this list can then be iterated in the following way

 

var myString = 'x y z';
aqString.ListSeparator = ' ';
for (var i=0; i < aqString.GetListLength(myString); i++){
    Log.Message(aqString.GetListItem(myString, i);
}

This allows me to cycle through the items in my string and get the individual values.  You can then compare the individual values to individual items in your item list in your drop down control.  Obviously, there's more code to be involved in doing that but this is the basics of using a list of string items.

Technically speaking, you could do something similar in reverse with what's in wItemList.  You just need to know what the ListSeparator character is to make that determination.


Robert Martin
[Community Expert Group]
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
Extensions available
Community Hero

Re: how to compare the items in the witemlist and the values passed in excel sgould be equal.

Actually, you know what, I'd do it in a series of checks... 

So, it's a dropdown/combo box.  I'm guessing Windows Desktop application.  So, first comparison is to compare the lengths.  If they don't match, don't bother.  Then, once we know the lenghts match, we just go down the line, item by item.

var excelList = 'x y z';
aqString.ListSeparator = ' ';
if (Aliases.MyApp.MyForm.MyComboBox.wItemCount)  != aqString.GetListLength(excelList)) {
   Log.Error('The list lengths don't match');
}
else {
    for (var i=0; i < aqString.GetListLength(excelList);i++){
       if (Aliases.MyApp.MyForm.MyComboBox.wItem(i) != GetListItem(excelList(i))){
            Log.Error('List item ' + i + ' does not match');
        }
    }
}

Robert Martin
[Community Expert Group]
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
Extensions available
New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors