Forum Discussion

mrezahoseini's avatar
mrezahoseini
Contributor
10 years ago

comparison between two strings

Hello

 

I use a file(PerdiocRequest) , which has been attached, inorder to make a string by this code: 

 

var Driver = DDT.ExcelDriver("C:\\PeriodicRequest.xls", "Sheet1");

var m =Driver.Value(0);
m = aqConvert.VarToStr(m);
var k= Driver.Value(1);
k = aqConvert.VarToStr(k);
var z = Driver.Value(2);
z = aqConvert.VarToStr(z);
var y = Driver.Value(3);
y = aqConvert.VarToStr(y);

total =m+"-"+k+"-"+z+"-"+y;

 

Also, I have used an object, which has been captued and attaced as a jpg format, in the code it is called t1( AppType.frmGridDetails.tableLayoutPanel1.grpContent.tlpValues.lblValue3)

 

I compare total and t1 with each other. Althought they are the same, but the result is different.

 

Could anybody help me why is occued?

 

 

function Test1(AppType)

{
AppType.frmPeriodicRequest.tableLayoutPanel1.entityDataGridView1.dgvMain.Click(824, 41);
var Driver = DDT.ExcelDriver("C:\\PeriodicRequest.xls", "Sheet1");

var m =Driver.Value(0);
m = aqConvert.VarToStr(m);
var k= Driver.Value(1);
k = aqConvert.VarToStr(k);
var z = Driver.Value(2);
z = aqConvert.VarToStr(z);
var y = Driver.Value(3);
y = aqConvert.VarToStr(y);

total =m+"-"+k+"-"+z+"-"+y;

t1 = aqConvert.VarToStr(AppType.frmGridDetails.tableLayoutPanel1.grpContent.tlpValues.lblValue3.Text);

total = aqConvert.VarToStr(total);

 

 

if(t1 == total)
Log.Message("Equal");

else
Log.Message("Not Equal");


AppType.frmGridDetails.tableLayoutPanel1.btnOk.ClickButton();

DDT.CloseDriver(Driver.Name);
}

 

 

 

Image of t1(AppType.frmGridDetails.tableLayoutPanel1.grpContent.tlpValues.lblValue3)

 

2015-03-01_14-18-28.jpg

 

 

Excel File:

 

2015-03-01_14-25-08.jpg

 

 

 

 

 

 

1 Reply

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi mahnazreza,

    The easiest way to troubleshoot failed comparisons is to output both values to the test log, for example, using Log.Message. Or if you use property checkpoints to compare values, TestComplete will log the compared values automatically:

    total = m + "-" + k + "-" + z + "-" + y;
    
    aqObject.CheckProperty(AppType.frmGridDetails.tableLayoutPanel1.grpContent.tlpValues.lblValue3, "Text", cmpEqual, total);


    On your screenshots, the dialog shows "800-801-2-1" but the Excel file contains "800-801-100-1" - so the values are actually different.