Forum Discussion

GAutomation's avatar
GAutomation
Frequent Contributor
6 years ago

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?

  • tristaanogre's avatar
    tristaanogre
    6 years ago

    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');
            }
        }
    }
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    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.

    • GAutomation's avatar
      GAutomation
      Frequent Contributor

      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.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        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.