cancel
Showing results for 
Search instead for 
Did you mean: 

Value retrieved from the database need to match the value from UI

Super Contributor

Value retrieved from the database need to match the value from UI

I need to come up with the script 

 

Here is the case 

 

- Value retrieved from the database need to match the value from UI

 

I am using the DB table variables . I have stored the query in DB table variable. 

 

I can retrive the values from UI. 

 

Now I have to match the value from the database to that of UI. attached the screenshot.

 

My issue is how will I match the values.

 

Please advise 

 

Thanks

NG

 

 

4 REPLIES 4
Highlighted
Community Hero

Re: Value retrieved from the database need to match the value from UI

Super Contributor

Re: Value retrieved from the database need to match the value from UI

these are the check points . I am already using the property checkpoints. 

 

I looked at the database checkpoint but this will not slove the issue .

 

My concerns is how will I match the value that shows in UI to the database value. As in the database we are showing the values rows. In UI we are showing the same values in the one Text with spaces in between

 

For e.g

 

in database 

TB

TR

TT

In UI

 

TB TR TT

 

Thanks

NG

 

Community Hero

Re: Value retrieved from the database need to match the value from UI

There are all sorts of string operations you can use to pick apart the text with spaces

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/methods.html

 

What I might do is read the whole text string from the UI into a variable, then use Trim to take the spaces out.  After that you can loop through the string 2 spaces at a time and get the next pair out to compare to the database.  Or you could not take the spaces out and loop through 3 at a time and do the compare with the first two and skip the space.  Or if you don't mind destructive testing, you can compare to the first pair and then delete them so you are always comparing to the first two.

 

 

Community Leader

Re: Value retrieved from the database need to match the value from UI

If you are certain the UI will display in format [text][space][text][space][text], you could consider using .split.  Rough outline like so:

 

 

var UItext = holdcodesobject.contentText //This should be 'TB TR TT
var UISplitText = UItext.split(' ');

//Now compare one item at a time
for(var I=0;i<UISplitText.length;i++)
{
//depending on usage, you should be able to use one of the following

/// OPTION 1 if(!databale.IsEOF()) {
databale.MoveNext() //or the method that moves to the next current record
if(UISplitText[i]!=datatable.GetValue(0)) //can't recall the syntax for getting the value from column 0 - you will need to double check this
{
log.error("a field didn't match");
break;
} } else { Log.Error("No data in datatable"); }

//OPTION 2
if(datatablerowcount>0)
{ if(UISplitText[I]!=[datatable row i, column 0] //consider aqstring.ToUpper() and .Trim() on both sides.
{
log.error("a field didn't match");
break; } }
}
else
{
Log.Error("No data in datatable");
}

 

 

Also, your first check could be to make sure that your UIsplitText's length is the same as the record count of your datatable before you even compare the items per row.  If they aren't, there will obviously be an error in matching

 


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
New Here?
Join us and watch the welcome video:
Join the September Hub-bub to show off, learn and win