Sunday 27 October 2013

OUTPUT VALUES IN QTP



-> output values used to store run time values. its stored output values into variable only duration of the run session.The values can later be used as input at a different point in the test.

-> QTP allows user to retrieve run time value and stored them. Then its used for different stage of our test.

-> The output values are stored in Runtime datatable (Global Sheet or Local Sheet)

we can stored this output value into

   * A test ir Action Parameter
   * The Run time data table
   * The Evironmental Variable



The following categories are availble for Output values

   * Standard Output value
   * Text and Text Area output value
   * Database Output Value
   * XML output Value

* Standard output Value

The standard output values are used for retrieve and used the property values of the object.

In Recording Mode -> INsert -> output value -> standared output value -> select the object in app which we want -> select the object property value for want to used for output value-> select the name and location in datatable (Global sheet or Local Sheet) -> clik ok

* Text and Text Area output value

The Text and Text Area output value are used for retrieve and used the Text property values of the object.

In Recording Mode -> INsert -> output value -> Text output value ->select the object in app which we want -> select the object property value for want to used for output value-> select the name and location in datatable (Global sheet or Local Sheet) -> clik ok


* Database Output Value

In Recording Mode -> INsert -> output value -> Database output value -> ok

* XML Output Value

We can use the output value from the Elements in the XML file.

In Recording Mode -> INsert -> output value -> XML Output Value(Resources) -> select the XML file ->  XML Output Value property window open -> select the element and attribute values -> click <#> symbol in attribute value -> select the name and location in datatable (Global sheet or Local Sheet) -> click ok


Adding Existing output value into a test

-> QTP allows users to reuse the existing output values.

->Every time output value stpes run and replace the existibg values with new values.

Insert -> Output value -> Existing Output Value

DEBUGGING in QTP



Debugging is the process of locating and fixing the error in the scripting code.

We can set the breakpoint in the program to stop program execution and to isolate the defects.

After stops at breakpoint, we can see the debug viewer to check and modify the values of VBscript objects and value.



Debugging steps using breakpoint


We can insert the breakpoints from which step we want to debugging for verify the function working properly or not.

-> Insert Break point from where we want to use ( Debug -> Insert/Remove Breakpoint ( F9)

-> Run the record

-> QTP stop(Break) the step still where we insert the breakpoint.

-> Now From debug viewer, we can see/modify the variable value ( View -> Debug Viewer)

    -> Watch tab :

    -> Variables tab :

    -> Command tab :

-> While in Recording the test and break the test, we can debugging the each an every step using below options,

     -> Step Into :  (Debug -> Step into ) (F11)
                     ->    Its executed step by step line the text.
             -> If we have function or Action in the text, its go                         in to the function or Action and execute the step by                          step line.
             -> The QTP window visible the step by step test,function and Action.

    -> Step Out  :  ( Debug -> Step Out )
             -> Its executed step by step
                     -> If we have function or Action in the the text, and cursor placed in first line of the function or Action from the test. and will execute the still end of the function.
                      -> the cursor is paused first line of the statement, its only visible in QTP window. Then its process still end of the function, its not visbile in QTp window.But the step by step in test is visible.

    -> Step over : (Debug -> Step Over)

             -> Its executes step by step.
             -> IF we have function or Action in the test, its execute the whole statement in the function or Action. its not wait still we click the debug-> step over in each an every time.
             -> Its execute the whole function or Action, but its not visble in QTP window.But the step by step in test is visble.


Use this link for brief explanation -> http://www.qtphelp.com/2011/04/qtp-debugging-options.html           

RECOVERY SCENARIO


While the test is running if unexpected errors,events and application crashes will interrupt the run session. So its effect the running session.

EX: Pop up or advertisement may appear in website. This is may not occur during the recording session.its not unpredictable

Overcome this scenario QTP handle the recovery scenario.The recovery wizard proved the option to define the recovery scenario , which includes a definition of an unexpected event and the operation for necessary to recover the run session.

Ex:

1) unpredictable scenario:

Define the recovery scenario to handle the printer errors. if the printer errors occurs during the run session, the QTP instruct to click default 'OK' button in the error message.

2) Predictable scenario

we know the overwrite file manager box open when the save buttton clicked during the run session, you can handle this session to write 'IF' statement then click OK. In this type we no need to use recovery scenario.


Key Elements of Recoery Scenario

Trigger Event -> unperdictable event, error occured.(Ex:Pop up open)

Recovery operation -> the QTP process the recovery opertions. Ex: click 'OK' button in the check box.

Post recovery test run option -> its it instruct to QTP how its performed after recoery option option completed, and from which point text may run. Its may from next step of from starting point.



Creating Recovery Scenario:

* Recorey scenario contains following fine steps

    -> Define the Trigger Event that interrupts the run session.
    -> Specify the Recivery operation required to continue.
    -> Choose Post Recovery test for next run operation.
    -> Specify the name or description of the recovery operation.
    -> specify the whether to associate current recovery operation to current test or all test.

* There are 4 types of trigger events that disturb the script flow. they are

1) POP UP WINDOW -> Unexpected popup -> EX: Printer paper out pop up window
2) TEST RUN ERROR-> Return value of test script statement -> Ex:Item not available in list box.
3) OBJECT STATE  -> Change in property value of an object -> Ex: A button enabled from disbaled state.
4) APPLICATION CRASH -> Crash of the application -> EX : Application terminated by an operation during the run time.


POP WINDOW RECOVERY SCENARIO OPERATION

* Open Resoucres-> Recovery scenario manager


QTP TOOLS AND PANES



QTP provides various type of tools and panes for differnt purpose of the Automated testing

Step Generator: (F7)
Its enables to add the newst steps into the current step in the test.

We can insert by selecting steps category and entering required parameter values. the categories are

1) Test object operations (Captured Object present in the test)
2) Utility object operations (insert utility object such as datatable)
3) Functions operation ( insert the predefined(library) function in that step)

Insert -> Step -> Step Generator


Silent Test Runner:

Its enables to simulate way of the quick test runs from Load Runner and Buisness availability center, and to verify that your quick test is compatible with load runner and buisness avilability center.


Start -> All Programs -> Quick test professional -> Silent test runner -> give the test path to verify the compatible -> using the test run log we can verify


Active Screen:

->The Active Screen provides a snapshot of the object corresponding to the acive statement.

->In Active screen, we can see the current object location in the application

View -> Active Screen

Its take more memory, so its better to avoid in this pane.

For Active Screen settings, Tools -> options -> Active Screen


Missing Resource Pane:

-> The missing resource pane provides the list of resources which are not currently not avilable in QTP. Also indicates the location where the QTP is expected to find the resources.

-> view -> Missing Resource

-> Each time while in QTP run, its checks the all resources are currently available are not. If any one of the resource is not available, the missing resource pane display the all the resoources and location where QTP expected to find the resource. if the missing resource pan is not oopen that time, QTP automatically open this pane.

-> its display folowing resource if not available that time,

1) Missing Action
2) Missing Environmental variable file
3) Missing Function library
4) missing object repository
5) missing rcovery scenario
6) missing parameters


Information Pane

-> Its provides the infomation about the syntax errors or function library in your test.

-> View -> information pane


Password Encoder

-> This password encoder is used to encode the password.

-> Its enables to encode your passwords and place secure values into application. so others are not see those secure values in your test.

-> Start -> All programs -> Quick Test Proffesional -> Tools -> Password Encoder.

-> enter the text in password field. click the Generate button. Its generate the password.


Test Batch Runner

-> Its used to execute the group of test or series of tests at a time  is known as a Batch Execution.
-> For performing Batch testing, QTP is providing the seperate tools in called test batch runner.


open test batch runner:

Start -> All Programs -> Quick test professional -> Tools -> Test Batch Runner -> open more than tests to form like batches -> save as .mtb (Mudule Test bacthe) extension -> save and close

Run Test Batch runner:

click run after open batch or click batch -> run


Prior to run batch runner

check the option allwing other product to run the tests in eblo path

Tools -> options -> Run -> select Allow other HP products to run tests and componentes


Quick Test Script Editor:

-> Its enables to open and modify the scripts of multiple test and function libraries.

-> Also you can created new test and new function library. And you can modify the script of the test.

-> But you cannot modify the test and Associates the or remove associated function libraries.or change information existion names, test settings, parameterization and data tables.. those we cannot change

-> Start -> All programs -> Quick Test Proffesional -> Tools -> Quick Test Script Editor.


Register New Browser Control:

-> This browser contol adds the web application functionality like navigation, data download and other browser functionality to non-Web application.

-> This enables user to browse as well as in local and network folder with in the application.

-> Start -> All programs -> Quick Test Proffesional -> Tools -> Register New Browser Control.

-> Enter the absloute path .exe application hosting the browser control and click register. Also we can unregister.


Test Results Deletion Tool

We can use Test result deletion tool for list of all the test results in specific location in your system or in Quality center project.

-> Start -> All programs -> Quick Test Proffesional -> Tools -> Test Result Deletion Tool

We can delete the any test results that you no longer reguires by selecting the path location of the test results saved in folder. Select the test results file path and click "Delete". The selected test results are removed from those location


Remote Agent :

Activates the Remote Agent, its enables you to configure the Qucik Test behaves when the test is runs by Remote application like Quality center.

-> Start -> All programs -> Quick Test Proffesional -> Tools -> Remote Agent

Additional Installation Requirements :

This deialog box, which displays the any prerequest software that you must install or configure to work with Quick test.

-> Start -> All programs -> Quick Test Proffesional -> Tools -> Additional Installation Requirements





want to know more about that remote agent, Additional Installation requirement, Register new browser control


Window objects and Web objects


QTP support three kind of objects

1) Technology object
2) Utility object
3) Supplemental object

1) Technology object:

-> These object represent the test object of various technlogy object like Web,Windows and VB

-> Test Objects WebList,WebButton belongs to Web Technology (WEB OBJECT - Those object represent like links,images on the WEB page )

-> Test Objects WinEdit,WinButton,WinList belongs to Win Technology ( WIN OBJECT - This object displayed on desktop based application developed using standard windows object)

-> Test objects VBButton,VBList belongs to VB Technology.

This also means WebButton differnent from WinButton and VBButton.

2) Utility Object :

-> These Object represent to used commonly in all technologies.
-> For Ex. the data tables is an object used to store the data required by test script.
-> Since these object is used for all technology like Web,Window and VB.

3) Supplemental object :

-> These are additional object supported by QTP.


Commen methods or procedure used in Web or win objects.


Check Method:

Its comapare the actual value with expected value and verify the result. return the boolean value.
       
we can use checkpoint for perform this operation.

Syntax:

object.check verify

object -> test object
verify -> Required. its varianlt value. checkpoint of the object to verify the actual value with expected value.
Return value -> Boolean value ( true or false)


GetROProperty

Its return the current value of the test object property from the object in the application.

Syntax:

object.GetROProperty(property name)

property name = property of the test object name
Return Value = return the test object property value.


GetTOProperty

Its return the correct property description of the object property from the object present in the application.

Syntax:

object.GetTOProperty()

Return value: its retun the proerty description

Descriptive Programming : in QTP

Descriptive Programming :

QTP identify the object by property and method of object which present in the object repository.But desciptive programming is used when perform operation in object which is not present in the object repository.

How to do DP?

We can achieve this below two kind of operation.

1) placing the set of property and values directly in statement :

we can describe the object directly in statement by using

PropertyName:=Propertyvalue

General Syntax:

TestObject("PropertyName1:=PropertyValue1",.... "PropertyNameX:=PropertyValueX")

TestObject - The test object like WinEdit,WebButton,WebList etc...
PropertyName - Its identify object peroperty name
PropertyValue - Its identify object peroperty Value
Both are seperated by commas and should enclosed by quotation marks.

Consider below example using OR

Browser("Google").Page("Google").WebEdit("q").set "QTP referance"

Below example using DP

Browser("Google").Page("Google").WebEdit("type:=text","name:=q","html tag:=INPUT").Set "QTP referance"

you can use the variable if u want to use the variable value. you can assign the value into the variable name.

using above example

Myvar="q"
Browser("Google").Page("Google").WebEdit("type:=text","name:="&Myvar,"html tag:=INPUT").Set "QTP referance"


2) Using Descriptive object:

we can use the description object to return the property collection object containing the set of property objects. The property objects contains property name and value.

Using description object we can isert data into the Edit box in google search home page

Set MyDesc= Description.Create()
MyDesc("type").value="text"
MyDesc("name").value="q"
MyDesc("html tag").value="INPUT"
Browser("Google").Page("Google").WebEdit(MyDesc).Set "QTP referance"


Hierarchy of specifying test object description


Providing Property and value directly to the QTP script for identify the object without using object repository is called the programmatic description.

If we use desciprtive programmin in the statement of the script, its not allowed to use the object repository method in the statement,

Valid Statment in the script (Using the DP and description object)

Set MyDesc= Description.Create()
MyDesc("type").value="text"
MyDesc("name").value="q"
MyDesc("html tag").value="INPUT"
Browser("Title:=Google").Page("Title:=Google").WebEdit(MyDesc).Set "QTP referance"

Invalid statement in scripts( Using DP and OR)

Browser("Title:=Google").Page("Title:=Google").WebEdit("q").Set "QTP referance"

Inabove statment the WebEdit("q") object located from OR. the QTP is not retrive this object from OR because the parent object (Browser) is specified using descriptive programming.


Identify the property and values to be used in DP.


To identify the property and values for the object by using the Object spy or object repository manager.

In All object property window (OR manager), we can identify the correct property and values.Here in below description properties we have the property  name and values.

micClasss

In general, there are no such property names are available to deal deirectly with browser( we dont see the any kind of description property in OR for browser). In this case we have the dummy property is avilable for dealing with browser that is called micClass. Sice descriptive property expect atleast one property.

the below code is not work,because there is no logical name or property name to identify the browser.

Browser("").refresh

This is correct format as in below

Browser("micClass:=Browser").Refresh

micClass is used for the class type of the test object like Browser,Page,WebLiast,WebButton etc,



Script1:

Click google Search button using properties in the step

Browser("Title:=Google").Page("Title:=Google").WebButton("type:=submit","html tag := INPUT","name:=Google Search").click


Script 2:

Click Google Search button using description object

Set googlesearchobj=Description.Create()
googlesearchobj("type").value="submit"
googlesearchobj("html tag").value="INPUT"
googlesearchobj("name").value="google search"

Browser("Title:=Google").Page("Title:=Google").WebButton(googlesearchobj).click


Script 3:

Adding and removing properties of an object in DP

set googlesearchobj=Desciption.Create()

Set googlesearchobj=Description.Create()
googlesearchobj("type").value="submit"
googlesearchobj("html tag").value="INPUT"

Set addobj=Description.Create()
addobj("name").value="Google search")

googlesearchobj.add addobj(0)
Print("Number of properties" &googlesearchobj.count)
googlesearchobj.remove "type"


Script 4:

print the name of all links present in the application

Set linkDesc=Description.Create()
linkDesc("html tag").value="A"
Set googlelinks= Browser("Google").Page("Google").ChildObjects(linkDesc)
Print ("Nnumber of linkns are in this web page" &GoogleLinks.count)
for i=1 to googlelinks.count-1
    Print("Name of the liks present in tha application"&googlelinks(i).getROProperty("text")
next


Explain:

-> linkDesc("html tag").value="A" (A meand "Anchor" represent links)
-> ChildObjects - Retrive all Child objects in the web page.
-> GetROProperty - return the property value.


Script 5:

Select all check box in the Gmail Inbox

Set checkboxdesc= Description.create()
checkboxdesc("type").value="checkbox"
set checkboxccollection= Browser("Google").Page("Google").Frame("Mails").WebTable("Inbox").ChildObjects(checkboxdesc)
for i=1 to checkboxcollection.count
    Checkboxcollection.set "ON"
next

Working with File System in QTP



The automation script offten important to add, remove, wite,read,delete folders and files in the file system.

We are using the FSO (File System Object) object model. FSO is a collection of classes or objects to achieve this concept.

Script 1:

Write prgram to read data from text file.

Const ForReading=1
Dim fso,ts
set fso=CreateObject("Scripting.FileSystemObject")
Set ts= fso.OpenTextFile("d:\login.txt",ForReading)
while Not ts.AtEndOfStream
    print(ts.ReadLine())
Wend
Set fso=nothing
Set ts=Nothing

Explain

OpenTextFile(,1or 2,)- 1 for  Reading, 2 for writing
AtEndOFStream - Return false if not reached end of data in file
        Return true if reached end of data in file
ReadLine() - Read one line at each time


Script 2:

Write pgm for write data into text file

Const ForWriting=2
Dim fso,ts
set fso=CreeateObject("Scripting.FileSystemObject")
Set ts=fso.OpenTextFile("d:\login.txt",ForWriting,true)
For i=1 to 100
    ts.WriteLine("Hello")
Next
Set fso=nothing
Set ts=Nothing


Script 3:

Write pgm to print all lines which contains "hello" in the line
Const ForReading=1
dim fso,ts
set fso=CreateObject("Scripting.FileSystemObject")
Set ts=fso.OpenTextFile("D:\login.txt".ForReading)
While not ts.AtEndOFStream
    Strline=ts.ReadLine()
    if Instr(1,Strline,"Hello")>0 then
        Print(Strline)
    End if
Wend
Set fso=nothing
Set ts=Nothing


instr(1,Strline,"Hello") - Search String in the Strline from the first character abd return the value of the position of the first character where we can found the string.


Script 4:

Write the pgm to print the current folder name

Dim fso,fdr,fdrname
Set fso=CreateObject("Scripting.FileSystemObject")
Set fdr=fso.GetFolder(".")
fdrname=fdr.name
print(fso.GetAbsolutePathName(fdrname))
Set fso=nothing
Set fdr=nothing


Script 5:

write pgm to print all files in given folder

Dim fso,f1,fc,fdr
Set fso=CreateObject("Scripting.FileSystemObject")
Set fdr= fso.GelFolder("d:\testfolder")
set fc=fdr.Files
for Each f1 in fc
    print(f1.name)
Next

For Each - This for loop used when we done know the how many files present in tha folder.
If we dont know the start and End value for the loop, that time we can used For Each.


Working with XML in QTP



Extensible Markup Language

-> XML is deferent from HTML.

-> HTML is describes how to display the data. used to design data in web.

-> XML is used to defined the data, and focus on what data is.


Script 1

Loading XML file

SetXMLDta = XMLUtil.CreateXMLFromFile("D:\login.xml")


Script 2

Reading name of the root node

XMLDta = XMLUtil.CreateXMLFromFile("D:\login.xml")
Set XMLRootElmnt = XMLDta.GetRootElement()
Print("Root Elemement is="&XMLRootElmnt.ElementName)

Script 3

Enumerate attributes of the root node

XMLDta = XMLUtil.CreateXMLFromFile("D:\login.xml")
Set XMLRootElmnt = XMLDta.GetRootElement()
Set attrcol = XmlRootElmnt.Attributes
for i=1 to attrcol.count
    Set attr=attrcol.item(i)
    print("Attribute name =" &attr.name & " attribute values are="&attr.value)
Next

attr.name = its return the name of the attributes
attr.value = its return the value of the attributes


Script 4

Enumerate the Child element of the root node

XMLDta = XMLUtil.CreateXMLFromFile("D:\login.xml")
Set XMLRootElmnt = XMLDta.GetRootElement()
Set Childcol= XMLRootElmnt.ChildElements()
for i=1 to childcol.count
    childnam = childcol.item (i)
    print("ChilD Elements are =" &childnam.ElementName)
Next


Script 5

compare two XML file

set XMLFile1=XMLUtil.CreateXMLFromFile("D:\login1.xml")
set XMLFile2=XMLUtil.CreateXMLFromFile("D:\login1.xm2")
res = XMLFile1.compare(XMLFile2)
if res eqv True then
    msgbox("Two files are same")
else
    msgbox("Two files are different")
end if


Working with Database in QTP



ADO Object Model

-> Actvex data object
-> Enable your client application to access database.
-> Its also support while building client server and web application

RDS object model

-> Remote Data service
-> Its help to move data from server to client

RDO - Remote data object

DAO - Data access object

ADO Objects

Connection - Its hub od ADO, Provide method to allow to connect the data store.

Command - Designed to run SQL statements.

Stream - used to manipulate fields or records contain the stream of data

Recordset -


Ret


dim dnconnection

set con=CreateObject("ADODB.connection")
Set rs=CreateObject("ADODB.recordset")
   
con.open "Driver={Driver};server=MySqlServer;uid=username;pswd=password"
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

'Release objects'Release objects
Set rs= nothing
Set con= nothing

UTILITY OBJECT



Reporter object

After running the script we can see the pass or fail status in test result file. This kind of status reporting to result file can also be achieved by using Reporter object.THis object is used in below scenario,

-> Report the status of the step execution like pass,fail,warning to the test file.
-> Retrieve the path where the test results are stored.
-> Retrieve the current run status at the current point of the run session.
-> Enabling or Disabling reporting of the steps in test results.


Reporter Event

Its used to report the result status to the test results file.

Syntax:

Reporter.ReportEvent EventStatus. ReportStepName,Details

RepartEvent - 0 or micPass
        1 or micFail
        2 or micDone
        3 or micWarning

Reporter.ReportEvent micPass,"Demo Step","User Defined Step Pass"


Filter Property

Reporter.Filter = NewMode

NewMode may be 0 or rfEnableAll
        1 or rfEnableErrorsAndWarnings
        2 or rfEnableErrorsOnly
        3 or rfDisableAll

Its filter the test result status as per in the filter property newmode.

Reporter.Filter = 2
Reporter.ReportEvent micPass,"Demo Step","User Defined Step Pass"

Test report displays only enable errors report.

ReportPath Property

path = Reporter.ReportPath
msgbox(path)

Its display the path name where the test result path are stored.


RunStatus Property

Reporter.RunStatus

Its display the run status as per in perticular steps.



Crypt Object

This object used to encypt the strings

encypStr=Cript.Encrypt("psswd")


Environment Object


QTP Variables


What is variables?

Declaration of variables?

Option explicit statement

Assigning values into variables

usage of variables

Naming Restictions

Scope of variables

Type of variables

Array variables - Constant Array,dynamic Array, Dimensional array
        aAssiging series of value at a time


a) What is variable ?

-> Named memory location for storing or holding the information

-> The variable values change through out the program.

-> Primory memory -> RAM, Variable stored in primory memory. After execution

get completed, variable removed from primary memory location.

-> Secondary Memory -> Hard disk, CD-ROM, USB Drive


b) Declaration of variable?

using Pubilc,Private, Dim (99% used)

Syntax for DIM

Dim Variable name

Ex:  Dim a,b


c) Implicit and Explicit Declaration of variables

Explicit -> Declaring the variable then used in program is called the

Explicit declaration of the variable. ( This is best practice)

Implicit -> without declaration, directly we used variable in the program is

called implicit declaration. Default value for implicit variables is zero.


Example :

dim a=10
msgbox "Addition of" & a+b

o/p  Addition of 0    

Its not showing the error because VB script accept any variables and assign

default value to zero.if we want to throw error use option Explicit


d) Option Explicit Statement

Its forces to declare the all variable in the script. its show the error if

we are not declare in the script. Consider above example we get the error.

Its should be the first line in the statement

Example:

Option Explicit
dim a=10
msgbox "Addition of" & a+b

o/p  Error,   its show the error if we are not declare in the script.



e) Assigning values into variables

 we can assign the values in two types.

-> Initialization -> direct we assign the value

    Example:  Dim a=23

-> Reading -> its have 4 types

        a) Reading From input device (like keyboard or mouse)
       
        Ex: num2 = inputbox("Enter num2")

        b) Reading from files (Notepad or Excel)
        c) Reading from Databases
        d) Reading from application objects




Example ;

Dim num1,num2,res
num1 = 100       'Initalization
num2 = inputbox("Enter num2")    ' Reading
res num1+num2
msgbox res

O/P

Enter num2 200
300


Not : here num2 is string not a integer, because its value from inputbox.
here no need to convertion from string to integer.

because the concatenation symbol (Add + symbol), if both the values are

string, then we need conertion from string to integer. in above Example the

num2 value only string. So no need to convertion from string to Integer.





f) Usage of Variables

Stoing and holding the memory location

Different type of usage variable

-> Holding the data

a=100

-> Storing the value that returned by a program or code

a= (3+4) ^ 5    'exponantial function (7*7*7*7*7)
msabox a
   

-> Storing the object referance

set a = CreateObject ("Scripting.FileSystemObject")


-> As a parameter

For i=1 to 10 Step 1

    Browser("gmail").Page("gmail").WebEdit("userName").set i


   

   
g)Naming Restictions

-> Should start with aplhabets, not start with numbers

dim abc  'correct
dim 6gh   'incorrect

->Shold not contain Embeded period

dim as s     'incorrect
dim as.g     'incorrect
dim we-g      'incorrect
dim we*g    'incorrect
dim jo_e    'correct

-> must not required maximum 255 characters in length ( 1 tp 255 char)

-> must be unique in a scope of declaration

-> No duplicate variables

-> Vb Script is not a case sensitive language.so its treat as variable same

for both upper case and lower case.

Dim a,b,c   'correct
Dim h,B,r   ' incorrect no duplicate allowed.Shows Errr like "Variable

Redefined"


Standared naming restriction

The best practice if we follo below method, but QTP is not throw any error

message if you follow below methods

-> do not use any reserved words ( like Wait,Exit..)




h) Scope of variables

-> Program/Script level variables
-> Function/Procedure level variables

b=34
msgbox b

Function asb()
dim a=10
msgbox a
End Function

call asb()

msgbox a     ' o/p 0. if you are use option explict its shows error like

"variable is undefined"


i) Types of Variable :

-> Scalar variable or variable - its holding only one value at a time

-> Array Variables -> its storing series of values at a time based on type of array.

-> Associated array or hash variables - vbscriprt we dont have the hash

variable. but Vb script have the equalent feature. we are using dictionary

objects for hash variables.


Array variables

Constant Arrays

Its used when the size is defined

Ex:

Dim a,b(3)    ' b is array , its store 4 values its starts from 0 index.
b(0)=10
b(1)=34.32
b(2)="India"
b(3)= #10/10/2010#  
a= b(0)+b(1)
msgbox a


Note = if we are use b(4) in above examples, its shows error like "

subscript out of range"



Dynamic Arrays

its used when the size is undefined. if we want to use the dynamic array,

first define the size using redefined.

dim a,b(3),c()   'c is dynamic array variable
ReDim c(4)        '' its re define the array size, we should re define

the size before we using dynamic array

c(0) = 23
c(1) = 45 .....

Redim c(6)      ' now its store 7 values, we can redefine the size with in

same script and assign the values. its removed previous value.

c(0)=3
c(1)= 6 like that assign 7 value



Preserve keyword


used for keep the previous value



dim a,b(3),c()
ReDim c(4)

c(0) = 23
c(1) = 45 .....

Redim Preserve c(6)    ' its keep the previous value

c(5)=3
c(6)= 6






How to declare the dimensional array

vb script accepts 60 dimensional array. first number indicate rows and second number indicates column.

Dim a,b(2),c(),f(4,5)    ;f is two dimensional 4 is row and 5 is column. its stores the 30 values (5*6)  not (4*5). its starts from base 0.


isArray () function

its return the boolean value.its check whether the give variable is array variable or not. that means normal variable.


dim a(1)
msgbox IsArray(a)


o/p  True



Assigning series of value at a time

its achieved by two method

-> using array function
-> using split function


using array function


Example:

dim a
msgbox IsArray(a)  'False
a=Array("Array",100,34.23,#12/12/2003#)
msgbox IsArray(a)   'True
msgbox a(1)        'o/p = 100
msgbox a(2)        'o/p = 34.23


UBound() function

its used to find the how many values are hold by dynamic array variables.


dim a
msgbox IsArray(a)  'False
a=Array("Array",100,34.23,#12/12/2003#)
msgbox IsArray(a)   'True
msgbox a(1)        'o/p = 100
msgbox a(2)        'o/p = 34.23
msgbox UBound(a)    'o/p 4



using split function


dim a,b
b="VB SCRIPT LANGUAGE"
a= split(b)    ' its split thhe above sentence into 3 parts. its splitted

by space. space consider as delimeter
msgbox a(0)    ' O/p VB




dim a,b
b="VB@SCRIPT@LANGUAGE"
a= split(b,"@")    ' Here we are mention from which words we need to split
msgbox a(0)    ' O/p VB


dim a,b
b="VB@$SCRIPT@$LANGUAGE"
a= split(b,"@$")    ' Here we are mention from which words we need to

split
msgbox a(0)    ' O/p VB


here its stored as below
a(0) = VB
a(1) = SCRIPT
a(2) = LANGUAGE

How to work with Bugzilla



a) Its defect Tracking system or bug tracking system. its used to keep track

of the outstanding defects in prod effectively

b) Rest of thebug tracking systems are chaege enormous cost. But bugzilla is

free, but its proved the enormous contribution.

c) Major Features

->Tracks bug and code changes communicate with team mated. and submit and

review batches
-> It manage the Quality assurance.Its help you hadle on successful project

and communicate effectively to team members
-> Search Exisiong Bug reports
-> Enter a new bug report
-> Summary reports and charts

Why we use Bugzilla?
->its reduce downtime and improve the productivity.
-> Raise customer satisfaction and communicate to others
-> help to reduce cost by

IT support accountability
Telephon support knwledge bais
keep unusual software issues

-> its help for organization, regardless for siz of the employee

-> Possible use can be treated as

system Administration 
Deployment management
check design and development problem tracking



We can made below operation by Bugzilla


-> Search Exisiong Bug reports
-> Enter a new bug report
-> Summary reports and charts




How to Enter new bug into Bugzilla

a) Select Product -> for which we have defect in for perticular product.

Before that we should create seperate for every product bu bugzilla.we have

the only one produt default.

b) Select components -> its display list of components for above selected

Product. we have select at what component we have the bugs. Also its display

the componant descirption

c) version -> its dsiplay version of the above selected componanet.

d) Severity level -> Critical, Major, Normal Minor, blocker etc

Set blocked - its critical means fix asap.

e) select the platform -> PC,Macintosh, other

e) OS - windows, linux etc

f) Priority ->     P1 from P5

QTP Synchornization


-> Its part of error handling. but now a days independent topics.

-> its used to synchronize QTP with AUT for finding the error.


what is syncronization?

Global definition : This is process of matching speed of two things

QTP Definition : This is process of matching of speeds of Tool and application under test in order to get proper execution and result.


why synchronization?


During the execution we need synchornization . here two main concerns 1) Test design 2) Test Execution. we will got the problem during test execution.so that time we need Synchornization.

During the instruction QTP give instruction one by one with same speed. But application may take more time for execution. Here we are not blaming to application. because application not respond same speed for all the process.

Example:

Enter value into Editbox,select the check box or select the option box the application may respond the same speed. but downloading process or uploading process application respond speed is less.in order to keep both of the sync we need synchrinozation


when synchronization required?


QTP Default synchornization time is 20 second. if application need more than 20 seconds, that time we need QTP synchronizaion.

Example:

QTP not wait 20 sec for each an every statement in scripts. if one statement actual require 2 sec for respond, that time QTP goto next statement after 2 sec respond. its not keep on wait 20 sec normal time.

If another statement requires 27 sec for respond. QTP wait still 20 sec, but after 20 sec its show error.

In order to avoid the application, we need  to sync QTP and application(AUT).


How to Synchornization?


Three regular method:

a) Insert wait statement ( Vb Script feature)

syntax :

    Wait(time is seconds)  or wait  time in seconds( without paranthesis)


b) Inserting synchronization point ( QTP Tool feature)

Syntax :

Object heirarchy. WaitProperty "property name", property value, time in

milliseconds ( 1000 ms = 1 s)

c) Increase the QTP tool default time

File -> Settings -> Run -> Object synchronization timeout


Irregular method ( not for all scenario)

d) using Exist Property


Select appropriate methods

wait ("time in milliseconds");

The one drawback of wait() is its waiting for maximum time even though the application completed the operation.

Ex: wait (32)  or wait 32

Drawback of Wait ()

if the application reponsed at the time of 23, but here the maximum time is mentioned 32. so its waiting maximum time then goto the next statement. So remaining time 32-23= 9 sec the system in idle with out perform any operations. This problem is overcome by below synchronization point.


Synchronization Point

Its wait required time only, not maximum time.

Object hierarchy.WaitProperty "Peroperty name ", property value, time in milliseconds

If we want to insert wait () method, we can insert wherever we need synchronization after the QTP scripts.But if we want to insert synchronization point, we should consider below two things

1) Try to find on which object we need to implement synchronization point.
2) Try to find the above object property

Thses both steps are included and called object reference.



Example .

Example Script :

Browser("gmail").Page("gmail").WebButton("apply").click
Browser("gmail").Page("gmail").WebButton("ok").click


After click the apply for submit any form, the application need to wait the still submit the application. SO after submit the application the "OK" button is enabled and click "ok" for complete the process. Here still application submitted, the "ok" button is disabled.


Here we need synchronization point, because if application requires the 20 sec its not problem. But if the applicatin requires more than 20 sec, its shows the error like "the object is disabled". Because after  submit the application only "ok" button get enabled to click. we use above two methods for insert synchronizaion point.

For using Wait() for insert synchronization point

Browser("gmail").Page("gmail").WebButton("apply").click
wait 56
Browser("gmail").Page("gmail").WebButton("ok").click


Here the script is execute with out any issues. The above script instruct to wait the application still 56 sec. But if the application response in 30 sec, the remaining time executed process is wastage. so in order to avoid this problem, we can use snchronization point.


For using insert snchronization point

we should find the object name and object property for this method before synchronization needed.


Browser("gmail").Page("gmail").WebButton("apply").click
Browser("gmail").Page("gmail").WebButton("ok").waitproperty "enabled",True,30000
Browser("gmail").Page("gmail").WebButton("ok").click



-> So the above script the application wait still 30 sec. But if "ok" button is enabled (that means the application submitted) before 30 sec, the exected

process goto the next statement. Its not wait full 30 sec if sync completed.if the "ok" button is not enabled still 30 sec its shows the Error message like "The object is disabled"

For using insert snchronization point with out using time parameter

Browser("gmail").Page("gmail").WebButton("apply").click
Browser("gmail").Page("gmail").WebButton("ok").waitproperty "enabled",True,30000
Browser("gmail").Page("gmail").WebButton("ok").click

-> so the above scripts wait still the "ok" button gets enabled. the waiting time may any time. But we want to use carefully this operation, becaues for

failed case the execution process is waiting for long time.


For using QTP Tool insert the synchronization Point

a) Place the curser in script where we need the synchronization.
b) Recording mode-> select insert -> Synchronization Point -> select the object for which waiting for synchronization -> then select the Property name, Property value and select milliseconds.
c) Then finally the below cade added into the script

Browser("gmail").Page("gmail").WebButton("apply").click
Browser("gmail").Page("gmail").WebButton("ok").waitproperty "enabled",True,30000
Browser("gmail").Page("gmail").WebButton("ok").click


c) Increase the QTP tool default time ( Its tool feature)

File -> Settings -> Run -> Object synchronization timeout

This is applicable for all statement. If we setting the synchronization time out, the application wait for required time onlt. Not actual time for all statement in script

Example:

Consider we set the Object Synchronization Time out is 50 sec.If first statement 2 sec its not wait still 50 sec, its wait 2 sec and prcoess the statement and goto the next statement.

Tuesday 22 October 2013

QTP Mehods



QTP Test Process

1) Planning

2) Generation Basic Tests
   
    a) Object Repository Based Design
        i) Recording
        ii) Keyword Driven Technology

    b) Descriptive Programmiing
        i) Static Programming
        ii) Dynamic Programming

    Hybrid Approach
        High level







QTP Methods


Method. Set

1) Enter the value to Edit box/Text box

Sy: object.set "value"

2) Check/uncheck the Checkbox

Sy: Object.set "ON/OFF"

3) Select Radio button From a Group

Sy : Object.Set


Examples :  

1) Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "Arunrajvdm"
2) Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebCheckbox("Passwd").Set "ON"
3) Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebRadioButton("First").Set


Method - GetContent
-------------------
Return the content from Combo box or List box

Sy: Variable =object.GetContent

Example

Content = Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebComboBox("FlightFrom").GetContent
msgbox content


Method - CaptureMap
-------------------

Capture screen shot during execution and stores in specified location

Sy: object.CaptureMap "path to Store the file"


Batch Testing using QTP



Executing Punch of testcase or series of tests

For Manual testing, each an every tetscases have the human interactions. But Automation tool with out human interactions its run group of testcases.


Four possibilities for Batch testing

1) using "Test Batch Runner Tool"  (Tool Feature
2 )using AOM Scripts (Automation Object Model) Vbscript feature
3)Using Driver Scripts in Automation Framework
4) Using Quality Center Tool (Test Management Tool)



1) Steps For Batch testing using test batch runner tool


a) Generate Basic test and run them once.
b) Launch Test Batch Runner Tool and Create test batches
c) provide permission to Test batch runner tool to Execute tests
d) Run Test Batches



Example :

a) Generate the basic test and run them once

b) Launch Test batch runner tool and create test batches

Start-> Program-> HP QTP -> Tools-> Test Batch Runner

Test batch saved as ext .mtb (Module test batch)


Batch -> Add -> select the test  repeat this steps and add all the tests which we run bulk.




c) provide permission to Test batch runner tool to Execute tests


 QTP -> Tools -> options-> Select Run from option window-> Check Allow other HP products to run tests and components (CTRL+ALT+F5)


 
d) Run Test Batches (Test batch Execution Process)

Test Batch runner launches and give instruct to the QTP, then QTP run the tests. Test batch runner not execute the tests. QTP only Execute the test.

Based on instruction from testbatch runner, QTP execute the test one by one.


Launch Test batch runner which we saved as .mtb.-> Slect the test which we want to run -> from menu Batch-> Run (F5)


Then its automatically launches the QTP and run the tests

e) See the results

Open the each an every test -> See the result in Test Result viewer   

We cannot see the result in the Test Batch Runner Tool. For clear test reslt from Result viewer, we can use test deletion tool.


Advantage

-> We can run all batch test or Partial test at week end.


DisAdvantage

-> Its not provide the result as per the batch test.We need to open each an every test and analysis the result.


QTP supports three feautures

1) QTP direct features- Recording, Object Repository, Checkpoint,Datatable
2) Integrated Tool from HP -> Password Encoder, Test Result deletion tool , Test Batch Runner

3)


Manual testing -> its Sequential Testing. because output from one testcase,input of other testcase. because manual tetsing need human interaction.

Automation testing -> Its End to End Testing. because no need human interaction.

How to import data from database into DataTable

We are not follow any formalities if we using text or Excel file as resorces. But we follow some formalities if we use database as resources

a) Create a database
b) Create Tables
c) Enter test data

d) Create DSN (Data Source Name) 

ConnectionString - if we want to connect QTP to database, connection string is required for connecting QTP and database

Defualt location for store DSN

C:\Program Files\Common Files\ODBC\Data Sources

e) Read data using SQL statements


we no need to close the database if we are using in QTP. becuase its internally close that application.QTP is ready made environment


Vb Script Automation objects. For VB scripting , we can test the same as which we test in QTP script. But user need to define everything for Excel,datatabel in VB Scripting. But the QTP is provide ready made environment like Datatable. so no need to close that application.



Example :

1) Create a datable for login with below fields in MS Office Access

UserName     Password

Arun        12345
Raj        45454
Ajay         45457





See Screenshot of the Table from MsAccess in below





 

2) Import from datatable

a) Right click on datatable -> Sheet-> import-> From database





b) From Database Query Wizard-> select option Specify SQL Statement Manually -> click next





c)Below steps for create Connection String

First we create the new DSN and then its create the Connection String






Select the appropriate  Driver for our database. Here we are using the MsAccess for our database. so we choosing tje corresponding driver as Microsoft Access Driver(.*mdb)



Give the any value while create new data source



 So from above step we are create the new DSN.
DSN is different and our database is different. Now we are going to connect both DSN and our Database using below method.



 Select the database from our local machine





Now we are connected the DSN and Database. So its generated the Connection String automatically. We are retrieve the data manually by writing the SQL Query in below






After execute the above query, the data are imported into the below datatable



The above data are imported from database into the datatable. So now we can follow the normal way and syntax for using those data. the syntax are,

Steps for Data Driven Testing using Data table

1) Genrate Basic Test and run it once
2) Launch Data Table and enter / Imprt test data
3) Connect test Data to the test
4) Run the test

Syntext for connecting test data to test using datatable

DataTable(Column id/"Column name", Sheet id/ Sheet name)



Import and Export from External Resources into datatable

We can import or export from below resources in datatable

-> Text file
-> Excel File
-> Database

Steps for Data Driven Testing using Data table

1) Genrate Basic Test and run it once
2) Launch Data Table and enter / Imprt test data
3) Connect test Data to the test
4) Run the test

Syntext for connecting test data to test using datatable

DataTable(Column id/"Column name", Sheet id/ Sheet name)


if we want to use Text file as resource, we can follow two syntex in datatable

1) First line is consider as Column header
2) in between two cloumn tab space is delimiter
2) from next line, the datatable consider as data.



if we want to use Excel file as resource, we can follow two syntex in datatable

1) First Row is consider as Column header
2) from second row, the datatable consider as data.



If we want to import above two files. follow below options

From Datatable -> Right Click-> File -> Import From file-> select Notepad or Excel



> if we record the application, the below code values are static.


Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "Arunrajvdm"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "Arunrajvdm"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click



If we want to use dynamic values using datatable, we are following below below methods

1) use datatable and set the script as


Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set DataTable(1,1)      ' 1 for First col, 1 for First Sheet(Global)
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure DataTable(2,1) ' 2 for Second col, 1 for First Sheet(Global)
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click


2) Use keyword and set the Parameter using configuring the value for DataTable

Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set Parameter("UserName")
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure Parameter("Password")
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click


3) use Data Driven Method




Consider below static input scripts


Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "Arunrajvdm"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "Arunrajvdm"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click
 




Tools-> DataDriver -> Select Variable and click Parameterize -> Parameterrize All -> Select parameter-> Select Parameter Options for type as DataTable and set the Name and sheet global or Action1

see below screen shot, its shows as input variables are constent. So want to change dynamic using this method.




 Select variable name and set global Sheet for Datatable






After that its set script as below automatically

Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set DataTable("UserName", dtGlobalSheet)
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure DataTable("Password", dtGlobalSheet)
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click



Monday 21 October 2013

QTP DataTable



->This is one of the resources for passibg dynamic values into QTP parameters


Global Datasheet -> The variable value which is used for all Actions

Action Datasheet -> The variable value which is used for only seperate Actions.

Rename Datatable Parameter name -> select the column which we want to change the parameter name->and double click for change the name

Datatable type :

-> Design time datatable  -> we give the input to the input parameter
-> Runtime datatable -> we can see the ouput

once the QTP run ends, its stored the results in Runtime datatable. So if we want to see the result goto
'Automation -> Results -> Run time datatable - to see the reults

The run time table is not saved in our design time datatable. we can see the result in our local system in below path = E:\arunraj\qtp\datatable1\Res3\Report\Default.xls




Script for Adding two values from datatable

datatable.GetSheet(1)        'here Sheet id 1 for global, 2 for Action 1 and so on.
GetRowcount1 = datatable.GetRowCount
For i=1 to GetRowcount1
    datatable.SetCurrentRow(i)
    in1=datatable.Value(1,1)         ' Parameter ID = 1 mean for input 1, and Parameter id =2 for input 2 and so on.  Sheet ie =1 for Global
    in2 = datatable.Value(2,1)
    datatable.Value(3,1)=cint(in1)+cint(in2)     ' Value from datatable is String, so we convert into Integer using cint function
Next

' The results are stored in runtime data table. its not stored in design time datable in below. So if we want to see the result goto
'Automation -> Results -> Run time datatable - to see the reults








Result from run time table ( Automation -> Results -> Run time datatable - to see the reults)









Script for Read the values from Excel and Store the values into the Excel

DataTable.Import("File Name") = Read the Values from Excel

DataTable.Export("File Name") = Insert the Values into the  Excel


Note: The Excel file should have the older version (.xls). The new version is not support under QTP.


Create the new Excel and save into "C:\Users\user\Desktop\Action Image\Datatable1.xls"




Extract all rows from above Excel and insert into datatable in QTP.then below method are same as which we are using in datatable


The Script is

datatable.Import("C:\Users\user\Desktop\Action Image\Datatable1.xls")  'Extract all rows and insert into datatable , then below method are same as which we are using in datatable
datatable.GetSheet(1)
GetRow = datatable.GetRowCount
For i=1 to GetRow
    datatable.SetCurrentRow
    in1=datatable.Value(1,1)
    in2=datatable.Value(2,1)
    datatable.Value(3,1)=cint(in1)+cint(in2)
Next
datatable.Export("C:\Users\user\Desktop\Action Image\Datatable2.xls)




Then the results are stored into datatable2 Excel by using Export method


  



Delete the row from datatable

-> IF we select row and press delete button, the row from datatable is not permanantly deleted. The rows are still in datatable
-> if we want to delete the row from datatable use below method
    a) select row and press CTRL+K
    b) select row -> Edit-> delete


Working with datatable

QTP supports 3 objects named

-> Datatable
-> DTParameter
-> DTSheet

Script 1:

write program to import excel sheet to data table

Datatable.import("D:\EmpData.xls")


Script 2:

Write pgm to read data from the first parameter of global sheet

datatable.Import("E:\arunraj\notes\QTP\Example.xls")
Set dsGlobal = Datatable.GetSheet("Global")
set pmfirst = dsGlobal.GetParameter()
ds_Global_Row_Count = dsGlobal.GetRowCount()
print(pmfirst.Name)
for i=1 to ds_Global_Row_Count
print(pmfirst.ValueByRow(i))
Next



Script 3

Write pgm to read data from all sheets and all parameter of excel file

datatable.Import("E:\arunraj\notes\QTP\Example.xls")
Set countsheetobj=datatable.GetSheetCount()
For sheet=1 to countsheet1
    Set currentsheetobj = datatable.GetSheet(sheet)
    Set paramcount=currentsheetobj.GetParameterCount
    Set rowcount = currentsheetobj.GetRowCount
    print (currentsheetobj.Name)
    For row=1 to rowcount
        rowdata=""
        For param=1 to paramcount
            Set currentparam=currentsheetobj.GetParameter(param)
            rowdata= rowdata & vbtab & currentparam.ValueByRow(row)
        Next
    print(rowdata)
    Next
 Next



Script 4

Write pgm to insert data into the sheet in excel.

datatable.Import("E:\arunraj\notes\QTP\Example.xls")
Function PlaceDate(SheetName,ParamName,RowNumber,DataToAdd)
Set ParamObj= Datatable.GetSheet(SheetName).GetParameter(ParamName)
paramobj.ValueByRow(RowNumber)=DataTOAdd
End Function

PlaceData("Action1","Sheet1","5,"Demo USer")




Datatable using Hybrid Approach :(Using the DataTable by coding)

We are mixing the Readymade environment provided by QTP and Programmetic procedure



Datatable type :

-> Design time datatable  -> we give the input to the input parameter
-> Runtime datatable -> we can see the ouput. This is carbon copy of Design time dataTable


Script


1) Create Sheet at run time dable.

 By default Runtime DataTable have two sheets Global and Action1. So if we are add any sheet it placed from third sheet.

Syntax: DataTable.AddSheet "Sheet Name"

DataTable.AddSheet "login"

The sheet login placed in third place.

2) Import test data from an External File

Syntax  :  DataTable.importSheet "file name",Sheet from local Excel Source file, Sheet number from Destination DataTable Run time table

DataTable.importSheet "c:\login.xls",1,3

File Name = c:\login.xls
1 = Sheet number from Source File
3= Sheet number from Destination DataTable Run time table.



3) Syntax for DataTable ()

Syntax: DatatTable(Column number of Sheet from datatable, Sheet number of Datatable)

Ex: DataTable(2,3)

We can access the data from Third Sheet and all data from Second column in Data Table



Actions in qtp and type

What is action?

Acion is nothing but the set of task to perform some task, Every statement have to do some task in the application. This is called Action


Purpose of the Action

-> Reusability
-> Readability
-> easily locating errors

Types of Actions

-> Resuable Actions ( Default in QTP 11)
-> Non reusable Actions
-> External Actions
-> Opertions on Action


Example

As per the requirement create 3 Actions


Create a New Action                             Split Action

1) Create Required No of Action     1) Generate Entire Script into
(n-1)                                                         Default Action
Ex. Above Requirement we create          
only 2 action. + default Action=
total 3 Actions

2) Generate Script for our                2) Split the default Action. We can
every Action.                                        split one Action into two Action
                                                           at a time. not more than that.




1) Create a new Action


If we want to create a three Action as per our requirements, create 2 (n-1) Action, by using below method. we have already default Action, so totally three Actions we have in application.

INsert -> Call to New Action


Rename Action

Edit -> Action -> Rename Action


Delete Action

Select action From drop down box -> Edit -> Action -> Delete Action (But we cannot delete the Default Action. Atleast we have one Action in test)


Rename Action

Select action From drop down box -> Edit -> Action -> Rename Action




Test Pane in left side

View - Test Pane  ( its showing the sequence for Action Executions. we can change the test flow using drag and drop.)

Action Drop down

Its shows the all Actions in alphabetical order.



2) Split Action

If we our requirements using the Split Action, we should write all the script  under one Action, then we can split into one Action into Another Action.

We have below two options while Split the Actions

INdependent of each other  -> Max we used
Nested



How to change from Reusable Action to Non Reusable Action

1)Select the Reusable Action From Drop down box in Test pane
2) Edit -> Action -> Action Properties -> UNcheck the Reusable Action -> Click ok



How to record using three different Actions

1) Select First Action record whatever we want under this Action.
2) select newxt Action Still in under Recording mode, and record the which ever we want under Second Action.
3) Select Third Action Still under Recording Mode, and record which ever we want under third Actions.



How to call Existing Action


-> We should call the only Existing Reusable Action.we cannot call the non-Reusable Action existing in test.

-> Insert -> Call to Existing Action -> Select the test and select the Existing Resusable Action present in the test.

->  we cannot make any changes in the test which we are call  to Existing Action. Its Read only mode.


How to call to copy of Action

-> We can call both Reusable Action and non-Reusable Action existing in test.

-> Insert -> Call to copy of Action -> Select the test and select the Existing Resusable Action present in the test.

-> we can add, delete, Modify the Action. Because its Write Mode.



Action Parameters


Two type of Action Parameters

1) Input Parameters -> we can pass multiple dynamic values
2) Ouput parameters     -> Its used for return the ouput


-> Select the Action where we implement the input parameter for use dynamic values -> Edit -> Action -> Action Parameters

->  In window select Parameters tab. under this tasb we can see the below two options

a) Input Parameters
b) ouput Parameters


From TEST1 : Give the Variable name, Variable Type, Default Value, Descriptions and click ok




->From TEST1, Connect the parameters or passing the values

and set the parameter as synex: Parameter("Parameter Name ")

Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set Parameter("UserName")
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure Parameter("Password")
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click




-> From TEST2,  Create new test and call the Existing Action and set the parameter value in under default action new test. set the parameter value as

RunAction "Login [Login]", oneIteration,"Ajay","raj"





-> This is for we are passing one one dynamic Values. But if we want to pass more than one values, that time we need resources like datatable,Excel etc..





-> give the Defualt value in Parent Action Parameter