QTP database connectivity and integer comparison

Here’s a quick summary of what happened in last few weeks. Looks like this days I am spending more and more time with QTP and LoadRunner. Looks like, it would be a while before I can write back on the SOA testing. So, here goes.


The scenario was simple. There is a dynamic value in screen which needs to be compared with database. Simple, right. Well, for some reason, things didn’t go exactly as planned.

First, capture the value from database and then capture the value from UI. That didn’t go as planned, because, the value in database only gets generated when user perform some specific tasks in UI. So, first capture the value from UI and then capture the value from DB.

So, here is a pretty straight forward to capture an output from UI.


Browser(“Browser”).Page(“Somesite”).WebEdit(“ssousername”).Set “something”

Browser(“Browser”).Page(“Somesite”).WebEdit(“password”).Set “seomthing”


Browser(“Browser_2”).Window(“somewindow”).Page(“Save Comments”).Output CheckPoint(“adj_out_text “)

Here, comes the first problem. The screen itself is dynamic, and no way we could capture the specific value using text output by defining the text before and text after. It’s all or none. So, instead of capturing ‘1’, we are capturing ‘Value 1 is created’.

Well, nothing that can’t be solved with a bit of string manipulation. So, we did the following like in excel, by using MID.

2. c2=datatable.Value(“adj_out_text”,1)


Now, after we get our value, we need the get the value from database and compare.


Dim strConn

strConn = “Driver= {Microsoft ODBC for Oracle}; ” &_

                  “ConnectString=(DESCRIPTION=” &_

                  “(ADDRESS=(PROTOCOL=TCP)” &_

                  “(HOST=something) (PORT=1521))” &_

                  “(CONNECT_DATA=(SERVICE_NAME=something)));uid=something; pwd=something;”


Dim obConnect

Dim obRecset


Set obConnect =CreateObject(“ADODB.Connection”)

Set obRecset = CreateObject(“ADODB.Recordset”)


sql=”select  * from something”


obRecset.Open sql,strConn

datatable.GetSheet(1).AddParameter “DB_Adj_no”, “”
Do while Not obRecset.EOF





We get the value from dB and stored it in runtime. Though it’s not necessary, just to see in the results table. Now. Go ahead with Micpass.


If c7=c1 Then

                Reporter.ReportEvent micPass,”Values matched”,”Calculated Correctly ” & c1 & ”  = ” & c7


                Reporter.ReportEvent micFail,”Values Did not match”,”Did not calculate correctly ” & c1 & ” != ” &  c7

End If

Not a good result. Out report is showing Micfail, with 1 !=1. That’s weird.

After some head scratching, we thought we found out the reason. The string manipulation is giving us a string in return. We should convert that to a number and that should give us MicPass.





We already checked that the value in DB is number. But, still we are getting Fail. So, we go ahead and converted the DB output into number (integer, to be precise; same as the previous one).






Voila, now it’s all working good. At last, we are getting 1=1.


, , , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: