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.   ...
  • 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');
            }
        }
    }