Saturday, June 11, 2011

About Scripts

Scripting Language
A scripting language is a particular syntax used to execute commands on a computer. A program composed of commands from a particular scripting language is referred to as script.

Difference between Client Side Scripting & Server Side scripting
Client side Scripting
  1. Client side scripting is programmatic code in an HTML file that runs on the browser.
  2. Client side scripting is commonly written using java script language.
  3. A client side script is not processed at all by the web server, only by the client. It is the client’s responsibility to execute any and all client side scripts.
Server Side Scripting
  1. Server side scripts are scripts that execute on the web server. These scripts are processed and their output is sent to the client.
  2. The client does not receive any code from server side scripts; rather the client receives just the output of the server side scripts. Client side scripts and server side scripts cannot interact with one another because the client side scripts are executed on the client after the server side scripts have finished processing completely.
  3. Vbscript is example of server side script
Difference between Java script and VB Script
Javascript -
  1. It is client side scripting language, developed by Netscape.
  2. It is case sensitive.
  3. File extension is .js.

VBscript -
  1. It is both Client and server side scripting language,developed by Microsoft.
  2. It is not case sensitive.
  3. File extension is .vbs and .vba.

Wednesday, May 25, 2011

QTP-File Extensions

Hi Folks,

Following are type of file extensions used in QTP.
  1. function library files = .vbs, .qfl and .txt
  2. local object repository file = .mtr
  3. shared object repository file = .tsr
  4. recovery scenory file = .qrs
  5. Default.cfg :- "Microsoft Office Outlook Configuration File"
  6. Default.xls :- "This is the copy of the internal datatable which is there by default. 1 sheet is Global, other sheets are as per the Action names"
  7. Login.usr :- "It is a kind of default constant file where all the inbuilt vaialbles are assigned some values or otherwise"
  8. Script.mts :- "This is just the scripts as per each action. Whatever you write in each action will be saved here"
  9. thick_usr.dat :- "It is a kind of default constant file where all the inbuilt vaialbles are assigned some values or otherwise"
  10. thin_usr.dat :- "It is a kind of default constant file where all the inbuilt vaialbles are assigned some values or otherwise. It consists of less no. is variables than thick_usr.dat"

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

QTP-Parameter Types

What is Parameter and Types of Parameters in QTP?

Parameters facilitate re-usability of an Action or a Test. By using parameters, you can record a test once and use it several times. Parameters enable you to run multiple sets of data.

Note: An input Parameter is a placeholder for a value that is passed to the test during the test run.

Parameter Types: By default, a test runs once for the recorded values. To run a test for multiple values,parametrize the test. The types of parameters in QuickTest are:

1. Input parameter: Enables you to run a test using different sets of input values.

For example, you can use input parameter to select different destinations for the same source in the Flight Reservation Application .

2. Output parameter : Enables you to use output to capture values from the application at run-time. You can get a value from the application and store it in the QuickTest test Results. You can later use this value as an input to a variable.

3. Random Number parameter: A system-generated number that is generated during a test run.

4. Environment parameter : A variable that describes a software or hardware object in the application under test environment. Examples are operating system version or Local host name.