Forum Discussion

Anumakonda_mahe's avatar
Anumakonda_mahe
Frequent Contributor
12 years ago
Solved

Compare Object Properties Values with Excel Sheet column Values

Pls. let me know how to Compare Object Properties Values with Excel Sheet column Values



in our product we have Audit trails screen and it contains more than 10 fields. so i had created object check point for entire screen. now i would like to check each field value with excel sheet values.



  1. Registered records using DDT.exceldriver .


  2. Our product creates audit trails for each record.


  3. So now I have to compare audit trails screen values with excel sheet values


  • Small change



    for j:= 0 to dict.Count -1 do

    begin



    if VarToStr(dict.Item(key)) <>  VarToStr(dict1.Item(key1)) then



    Log.Error('Mismatch : Expected value for label '+ key +'  is  :  ' dict1.Item(key1))  + ' but found on screen is ' + dict.Item(key))  )   



    end;


5 Replies

  • Small change



    for j:= 0 to dict.Count -1 do

    begin



    if VarToStr(dict.Item(key)) <>  VarToStr(dict1.Item(key1)) then



    Log.Error('Mismatch : Expected value for label '+ key +'  is  :  ' dict1.Item(key1))  + ' but found on screen is ' + dict.Item(key))  )   



    end;


  • Hi,

    As I see from your screenshot the values are in tabular form.You can read these values from the screen and save them to a dictionary.For example



    //get the reference of the table object on the screen and save it in a variable

    tableDetails := yourtableobject;



    //Read the values on the screen  including the Label field and value field and label will be the key in dict



    dict := sys.OleObject['Scripting.Dictionary'];

    for i:=0 to tableDetails.Rows.Count -1 do

    begin

    dict.Add(tableDetails.Rows.Column[1].innerText,tableDetails.Rows.Column[2].innerText) //the syntax may not be right

    end;



    //Once you add all your screen values to the dictionary now can read the expected excel values which you need to compare with in the same way into another dictionary say Dict1



    //Now you have two dictionaries you can loop through them and compare them

    //here Dict and Dict 1 will have the same record count unless some field is missing on your screen but present in your excel sheet or viceversa if thats the case you can straightaway log it as a error if you want to



    key := dict.Keys;

    key 1:= dict1.Keys;

    //according to your screen shot i am imagine that both the excel has 4 records and your screen has 4 as well, to be compared

    for j:= 0 to dict.Count -1 do

    begin



    if VarToStr(dict.Item(key)) <>  VarToStr(dict1.Item(key1)) then



    Log.Error('Mismatch : Expected value for label '+ key +'  is  :  ' dict1.Item(key1))  + ' but found on screen is ' + dict.Item(key))  ) 
      



    end;


  • Anumakonda_mahe's avatar
    Anumakonda_mahe
    Frequent Contributor
    Thanks for your reply our product is developed using .Net can i have code in VB script