How to use Parameter in QTP
To use parameter in QTP, first we need to declare it in QC under parameter tab. If you want to define Input parameter then, you have to define it in input section. If you want to define output parameter then you have to define it in output section. Parameter name should be same in QC and QTP script.
Steps
pagenm="Google"
URL=http://www.google.com/
SystemUtil.Run "iexplore.exe",URL
reporter.ReportEvent micPass,"IEopen","Google open"
Err.Clear
Dim testset, n
Set testset = QCUtil.CurrentTestSet
n = testset.name
If Err.Number <> 0 Then
Errr.Clear
End If
End If
Parameter("OutURL")=""
Set Currobj=Browser("title:="&browsernm,"CreationTime:=0").Page("title:="&pagenm)
Currobj.WebEdit("name:=q").Set Parameter("Searchstr")
reporter.ReportEvent micPass,"searchvalue","search value set successfully"
else
reporter.ReportEvent micFail, "searchvalue","search value not set successfully"
End If
End If
Sample Script2
Err.Clear
Dim testset, n
Set testset = QCUtil.CurrentTestSet
n = testset.name
If Err.Number <> 0 Then
Errr.Clear
End If
Parameter("InURL")=""
end if
End If
To use parameter in QTP, first we need to declare it in QC under parameter tab. If you want to define Input parameter then, you have to define it in input section. If you want to define output parameter then you have to define it in output section. Parameter name should be same in QC and QTP script.
Steps
- Create first component
- Define input and output parameter in QC
- Declare parameter value in QTP script
- Assign value for input parameter in QTP, example parameter(“SearchStr”)=”string for search value”
- Use the input parameter in control
- Use run time value and assign it to output parameter for use in QTP, example parameter(“outurl”)=”www.google.com”
- Now, make second component
- Use first component’s output parameter as input value in second parameter.
- Follow same steps as mentioned in first component.
- Now to run the QC and use parameter create test case in test plan module.
- Pull the first and second component in test case.
- Give input value in first component for run.
- Check use output value of previous component checkbox in second component.
- Integrate test case with test lab.
- Run the test case from QC.
- It will take input search string from first component and output value of first component is used as input of second component and execute whole test combine.
Dim browsernm,pagenm
browsernm="Google"pagenm="Google"
URL=http://www.google.com/
SystemUtil.Run "iexplore.exe",URL
reporter.ReportEvent micPass,"IEopen","Google open"
‘code for debug and error handling purpose
On Error Resume NextErr.Clear
Dim testset, n
Set testset = QCUtil.CurrentTestSet
n = testset.name
If Err.Number <> 0 Then
Errr.Clear
End If
'Debug Declaration
If n = "" Then
Parameter("Searchstr")="Parameter Test in QTP"End If
Parameter("OutURL")=""
Set Currobj=Browser("title:="&browsernm,"CreationTime:=0").Page("title:="&pagenm)
If parameter("Searchstr")<>"" Then
If Currobj.WebEdit("name:=q").exist ThenCurrobj.WebEdit("name:=q").Set Parameter("Searchstr")
reporter.ReportEvent micPass,"searchvalue","search value set successfully"
Parameter("OutURL")=Currobj.WebElement("innertext:=qtp.blogspot.com/2007/11/qtp-test-parameters_11.html").GetROProperty("innertext")
reporter.ReportEvent micPass,"linkvalue","Link value set properly"else
reporter.ReportEvent micFail, "searchvalue","search value not set successfully"
End If
End If
Sample Script2
Dim browsernm,pagenm
On Error Resume NextErr.Clear
Dim testset, n
Set testset = QCUtil.CurrentTestSet
n = testset.name
If Err.Number <> 0 Then
Errr.Clear
End If
'Debug Declaration
If n = "" ThenParameter("InURL")=""
end if
If parameter("InURL")<>"" Then
SystemUtil.Run "iexplore.exe",Parameter("InURL") reporter.ReportEvent micPass,"IEopen","Google open"End If
Hi,
ReplyDeleteFirst of all want to Thank You for your useful post.This Software Testing article is very useful for me. I would like to introduce
another good site which is having Software testing and QTP resource site, Have a look on QTPbook
I alredy know about what is parametrization.But now ly know that how to use.Thanks for the blog.
ReplyDeleteSelenium Training in Chennai | QTP Training in Chennai | Software Testing Training in Chennai | QTP Training in Chennai
Your sequence is very unique and vague. I can observe few more things which I left in my blog.
ReplyDeleteJava training in Chennai | Android training in chennai | IOS training in chennai
Excellent posts of the parameters of the blog..
ReplyDeleteSAS online training in hyderabad
My cousin recommended this blog and she was totally right keep up the fantastic work!
ReplyDeleteFunction Point Estimation Training
This comment has been removed by the author.
ReplyDeleteReally useful information.thanks for sharing
ReplyDeletesoftware testing course online
Thanks For Sharing Such an Informative Article.....
ReplyDelete24Layouts
Hi, thank you very much for new information, i learned something new. Very well written.It was so good to read and usefull to improve knowledge.Keep posting. If you are looking for any big data hadoop related information please visit our website.
ReplyDeletebig data hadoop training in bangalore.
Thanks for sharing useful information. I learned something new from your bog. It's very interesting and informative. keep updating. If you are looking for any Python programming related information, please visit our website Python training institute in bangalore
ReplyDeleteThanks for sharing useful information. I learned something new from your bog. It's very interesting and informative..
ReplyDeleteweb designing training in chennai
web designing training in omr
digital marketing training in chennai
digital marketing training in omr
rpa training in chennai
rpa training in omr
tally training in chennai
tally training in omr