Wednesday, May 18, 2011

QTP-How to use Parameter using QC

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
  1. Create first component
  2. Define input and output parameter in QC
  3. Declare parameter value in QTP script
  4. Assign value for input parameter in QTP, example parameter(“SearchStr”)=”string for search value”
  5. Use the input parameter in control
  6. Use run time value and assign it to output parameter for use in QTP, example parameter(“outurl”)=”www.google.com”
  7. Now, make second component
  8. Use first component’s output parameter as input value in second parameter.
  9. Follow same steps as mentioned in first component.
  10. Now to run the QC and use parameter create test case in test plan module.
  11. Pull the first and second component in test case.
  12. Give input value in first component for run.
  13. Check use output value of previous component checkbox in second component.
  14. Integrate test case with test lab.
  15. Run the test case from QC.
  16. 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.
 Sample script1

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 Next
Err.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 Then
Currobj.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 Next
Err.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("InURL")=""
end if

If parameter("InURL")<>"" Then
SystemUtil.Run "iexplore.exe",Parameter("InURL") reporter.ReportEvent micPass,"IEopen","Google open"
End If

12 comments:

  1. Hi,

    First 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

    ReplyDelete
  2. This is very useful. I also recommend you to check the following useful site: 100 Software testing Downloads

    ReplyDelete
  3. I alredy know about what is parametrization.But now ly know that how to use.Thanks for the blog.
    Selenium Training in Chennai | QTP Training in Chennai | Software Testing Training in Chennai | QTP Training in Chennai

    ReplyDelete
  4. Your sequence is very unique and vague. I can observe few more things which I left in my blog.

    Java training in Chennai | Android training in chennai | IOS training in chennai

    ReplyDelete
  5. My cousin recommended this blog and she was totally right keep up the fantastic work!

    Function Point Estimation Training

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Really useful information.thanks for sharing



    software testing course online

    ReplyDelete
  8. Thanks For Sharing Such an Informative Article.....

    24Layouts

    ReplyDelete
  9. 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.
    big data hadoop training in bangalore.

    ReplyDelete
  10. 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

    ReplyDelete