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.
1.
Browser(“Browser”).Page(“Somesite”).WebEdit(“ssousername”).Set “something”
Browser(“Browser”).Page(“Somesite”).WebEdit(“password”).Set “seomthing”
Browser(“Browser”).Page(“Somesite”).WebButton(“Login”).Click
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)
C1=mid(c2,12,3)
Now, after we get our value, we need the get the value from database and compare.
3.
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”, “”
c7=datatable.Value(“DB_Adj_no”)
i=1
Do while Not obRecset.EOF
DataTable.GlobalSheet.SetCurrentRow(i)
datatable.Value(“DB_Adj_no”)=obRecset.Fields.Item(0)
i=i+1
obRecset.MoveNext
Loop
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.
4.
If c7=c1 Then
Reporter.ReportEvent micPass,”Values matched”,”Calculated Correctly ” & c1 & ” = ” & c7
Else
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.
5.
c2=datatable.Value(“adj_out_text”,1)
c3=mid(c2,12,3)
c1=CInt(c4)
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).
6.
datatable.Value(“DB_Adj_no”)=obRecset.Fields.Item(0)
c5=datatable.Value(“DB_Adj_no”)
c6=trim(c5)
c7=CInt(c6)
Voila, now it’s all working good. At last, we are getting 1=1.