How can i check if a checkpoint passes or not?
check_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
if check _PassFail then
MsgBox "Check Point passed"
else
MsgBox "Check Point failed"
end if
How to add a constant number in a datatable?
This is more to do with MS excel then WinRunner / QTP.If add number to the Excel sheet, it will take default format. If you add ‘ to the number it will become constant.
Ex: if you wish to enter 1234567 in datatable then write it as '1234567
How can i check if a parameter exists in DataTable or not?
The best way would be to use the below code:
on error resume next
val=DataTable("ParamName",dtGlobalSheet)
if err.number<> 0 then
'Parameter does not exist
else
'Parameter exists
end if
QTP Script for connecting to database
Script for connecting to MS Access.
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider="microsoft.jet.oledb.4.0"
con.open"d:\testdata.mdb"
rs.open"select*from emp",con
Do while not rs.eof
VbWindow("Form1").VbEdit("val1").Set rs.fields("v1")
VbWindow("Form1").VbEdit("val2").Set rs.fields("v2")
VbWindow("Form1").VbButton("ADD").Click
rs.movenext
Loop
Database we are using here is MS-Access, before running this script create a table in MS Acess.
In the above script i used table called "emp" and column names as "v1" and "v2".
"d:\testdata.mdb" is path of the table which we created in MS Access.
Main use of this application is to use testdata of table(which is in database) in the application.
Script for connecting to sqlserver
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.open"provider=sqloledb.1;server=localhost;uid=sa;pwd=;database=testdata"
rs.open"select*from emp",con
Do while not rs.eof
VbWindow("Form1").VbEdit("val1").Set rs.fields("v1")
VbWindow("Form1").VbEdit("val2").Set rs.fields("v2")
VbWindow("Form1").VbButton("ADD").Click
rs.movenext
Loop
Script for connecting to oracle
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.open"provider=oraoledb.1;server=localhost;uid=scott;pwd=tiger;database=testdata"
rs.open"select*from emp",con
Do while not rs.eof
VbWindow("Form1").VbEdit("val1").Set rs.fields("v1")
VbWindow("Form1").VbEdit("val2").Set rs.fields("v2")
VbWindow("Form1").VbButton("ADD").Click
rs.movenext
Loop
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment