SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Visit:   www.gcreddy.com                         for QTP Information


               Types of Statements in QTP Test
We use different types of statements in QTP Test or Test script

i) Declarations
a) Declaring Variables

Dim strCity, intNum, objExcel, myDate

strCity="Hyderabad"
intNum=100
myDate=#10/10/2010#
Set objExcel=CreateObject("Excel.Application")

b) Declaring Constants

Const City="Hyderabad"
Const Login="text:=Login", Agent="window id:=2001", Password="attached text:=Password:"

ii) Comments
Ex1: Using Apostrophe (‘) symbol before the Statement
'Creating an Automation Object in Database Connection Class, that can be used to connect to
Databases (any Daatabase)

Set objConnection=CreateObject("Adodb.Connection")


Ex2: Using Rem Command followed by space
Rem Creating an Automation Object in FileSystemObject Class, that can be used to perform
Operations on Computer File system
Rem Using this Automation Object we can work with Folders and Files

Set objFSO=CreateObject("Scripting.FileSystemObject")



iii) Utility Statements
Examples:

a) Launching Windows based applications
SystemUtil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe"

Or
InvokeApplication "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe"

b) Launching Web based applications
SystemUtil.Run "C:Program FilesInternet ExplorerIEXPLORE.EXE","www.gcreddy.com"

c) Closing all decent process


         G C Reddy    (91-9247837478), QTP Trainer,INDIA                                      1
Visit:    www.gcreddy.com                         for QTP Information

SystemUtil.CloseDescendentProcesses

d) Defining Test Result

Reporter.ReportEvent micPass,"Result","Test Passed"

Reporter.ReportEvent micFail,"Result","Test Failed"

e) Using environment Variables
Environment.Value("ProductDir")

f) DataTable Operations
'Adding a Sheet to Run-Time DataTable
DataTable.AddSheet "Gcreddy"



iv) Object Calls
Examples:

a) Standard Windows Environment
Dialog("Login").WinButton("Cancel").Click

b) Visual Basic Environment
VbWindow("CALCULATOR").VbButton("CLEAR").Click

c) Web Environment
Browser("Google").Page("Google").Link("Gmail").Click

v) Flow Control Statements
a) Using If statement

If Total=Tickets*Price Then
        Reporter.ReportEvent micPass,"Res","Total is Correct"
        Else
   Reporter.ReportEvent micFail,"Res","Total is InCorrect"
End If

b) Using Select case Statement

Select Case Keyword
              Case "ln"
                     Result=Login("gcreddy@yahoo.com","abcd")
       DataTable(7,"TestStep")=Result

                     Case "ca"
                     Close_App()

                   Case "rn"
                   Result=Register("gcreddy2@gmail.com")
      DataTable(7,"TestStep")=Result



         G C Reddy     (91-9247837478), QTP Trainer,INDIA                        2
Visit:   www.gcreddy.com                        for QTP Information


              Case "al"
                   Result=App_Launch()
      DataTable(7,"TestStep")=Result
            End Select

c) Using For…Next Loop

For i=1 to MRowCount Step 1
       DataTable.SetCurrentRow(i)
       ModuleExe=DataTable(3,"Module")

      If UCase(ModuleExe)="Y" Then
             ModuleID=DataTable(1,"Module")
      Next
d) Using While…Wend Statement

While objRecordset2.EOF=False
Wscript.Echo objRecordset2.Fields.Item("DriveName"), _
objRecordset2.Fields.Item("DriveDescription")
objRecordSet2.MoveNext
Wend

e) Using Do While …Loop

Do While objRs.EOF=False
a=objRs.Fields ("Agent")
b=objRs.Fields ("Pwd")
myFile.Writeline a &","& b
r=r+1
objRs.MoveNext
Loop

f) Using Do Until …Loop

Do Until objRs.EOF
a=objRs.Fields ("gcreddy")
b=objRs.Fields ("qtp")
myFile.Writeline a &","& b
r=r+1
objRs.MoveNext
Loop

g) Using For Each …Next

For Each element In x
msgbox element
Next

vi) Function/Action Calls




         G C Reddy      (91-9247837478), QTP Trainer,INDIA                     3
Visit:    www.gcreddy.com                       for QTP Information

a) Function calls

Dim myDate
myDate=Date
Msgbox myDate
Msgbox NOW ‘Built-in Function

Call Login (“gcreddy”,”mercury”) ‘User defined Function

b) Action Calls

RunAction "Registration [Orders]", oneIteration

vii) Check point statements
Window("Flight Reservation").WinEdit("Name:").Check CheckPoint("Name:")

viii) Output value statements
Window("Flight Reservation").WinButton("Update Order").Output CheckPoint("Update Order")

ix) Synchronization point statements
Window("Flight Reservation").WinButton("Delete Order").WaitProperty "enabled", True, 30000

x) VB Script statements
Examples:

a) Synchronization using Wait Statement

Wait 10

b) Code Optimization Using With and End With Statements

With Dialog("Login")
       .Activate
       .WinEdit("Agent Name:").Set "vdfdg"
       .WinEdit("Password:").SetSecure "4d52b150608f41854dfd1714582004f58c475d84"
       .WinButton("OK").Click
End With

c) Defining Private Functions using Private statement

Private Function Login(UserId, Password)
--------
Statements
----------
----------
End Function

d) Storing Object Reference using Set Statement

Set myPage=Browser("QuickTest Professional").Page("QuickTest Professional")



          G C Reddy   (91-9247837478), QTP Trainer,INDIA                                     4
Visit:    www.gcreddy.com              for QTP Information


e) Declaring Variables using Public statement

Public strName, intPhNumber

‘*************************************************************

With Best Wishes




http://www.gcreddy.com/




         G C Reddy     (91-9247837478), QTP Trainer,INDIA             5

Weitere ähnliche Inhalte

Was ist angesagt?

Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS ProgrammersDavid Rodenas
 
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB
 
Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113SOAT
 
COScheduler In Depth
COScheduler In DepthCOScheduler In Depth
COScheduler In DepthWO Community
 
Vielseitiges In-Memory Computing mit Apache Ignite und Kubernetes
Vielseitiges In-Memory Computing mit Apache Ignite und KubernetesVielseitiges In-Memory Computing mit Apache Ignite und Kubernetes
Vielseitiges In-Memory Computing mit Apache Ignite und KubernetesQAware GmbH
 
The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.7 book - Part 16 of 196The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.7 book - Part 16 of 196Mahmoud Samir Fayed
 
The Groovy Way of Testing with Spock
The Groovy Way of Testing with SpockThe Groovy Way of Testing with Spock
The Groovy Way of Testing with SpockNaresha K
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest MatchersShai Yallin
 
The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189Mahmoud Samir Fayed
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartGabriele Lana
 
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...MongoDB
 
Vaadin 7 Today and Tomorrow
Vaadin 7 Today and TomorrowVaadin 7 Today and Tomorrow
Vaadin 7 Today and TomorrowJoonas Lehtinen
 
What's new in Android O
What's new in Android OWhat's new in Android O
What's new in Android OKirill Rozov
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydneyjulien.ponge
 
What's new and noteworthy in Java EE 8?
What's new and noteworthy in Java EE 8?What's new and noteworthy in Java EE 8?
What's new and noteworthy in Java EE 8?gedoplan
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overviewgourav kottawar
 
Converting Db Schema Into Uml Classes
Converting Db Schema Into Uml ClassesConverting Db Schema Into Uml Classes
Converting Db Schema Into Uml ClassesKaniska Mandal
 

Was ist angesagt? (20)

Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS Programmers
 
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
 
Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113
 
COScheduler In Depth
COScheduler In DepthCOScheduler In Depth
COScheduler In Depth
 
Vielseitiges In-Memory Computing mit Apache Ignite und Kubernetes
Vielseitiges In-Memory Computing mit Apache Ignite und KubernetesVielseitiges In-Memory Computing mit Apache Ignite und Kubernetes
Vielseitiges In-Memory Computing mit Apache Ignite und Kubernetes
 
The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88
 
The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210
 
Hidden rocks in Oracle ADF
Hidden rocks in Oracle ADFHidden rocks in Oracle ADF
Hidden rocks in Oracle ADF
 
The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.7 book - Part 16 of 196The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.7 book - Part 16 of 196
 
The Groovy Way of Testing with Spock
The Groovy Way of Testing with SpockThe Groovy Way of Testing with Spock
The Groovy Way of Testing with Spock
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
 
The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing Part
 
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
 
Vaadin 7 Today and Tomorrow
Vaadin 7 Today and TomorrowVaadin 7 Today and Tomorrow
Vaadin 7 Today and Tomorrow
 
What's new in Android O
What's new in Android OWhat's new in Android O
What's new in Android O
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydney
 
What's new and noteworthy in Java EE 8?
What's new and noteworthy in Java EE 8?What's new and noteworthy in Java EE 8?
What's new and noteworthy in Java EE 8?
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
 
Converting Db Schema Into Uml Classes
Converting Db Schema Into Uml ClassesConverting Db Schema Into Uml Classes
Converting Db Schema Into Uml Classes
 

Andere mochten auch

Manual Testing
Manual TestingManual Testing
Manual TestingG.C Reddy
 
Qtp training in hyderabad
Qtp training in hyderabadQtp training in hyderabad
Qtp training in hyderabadG.C Reddy
 
QTP Training
QTP TrainingQTP Training
QTP TrainingG.C Reddy
 
Qtp commands
Qtp commandsQtp commands
Qtp commandsG.C Reddy
 
QTP 10 00 Guide
QTP 10 00 GuideQTP 10 00 Guide
QTP 10 00 GuideG.C Reddy
 
Automation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadAutomation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadDurga Prasad
 
Manual Testing Notes
Manual Testing NotesManual Testing Notes
Manual Testing Notesguest208aa1
 
Manual Testing Material by Durgasoft
Manual Testing Material by DurgasoftManual Testing Material by Durgasoft
Manual Testing Material by DurgasoftDurga Prasad
 

Andere mochten auch (9)

Manual Testing
Manual TestingManual Testing
Manual Testing
 
Qtp training in hyderabad
Qtp training in hyderabadQtp training in hyderabad
Qtp training in hyderabad
 
QTP Training
QTP TrainingQTP Training
QTP Training
 
Qtp commands
Qtp commandsQtp commands
Qtp commands
 
QTP 10 00 Guide
QTP 10 00 GuideQTP 10 00 Guide
QTP 10 00 Guide
 
Selenium Handbook
Selenium HandbookSelenium Handbook
Selenium Handbook
 
Automation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadAutomation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabad
 
Manual Testing Notes
Manual Testing NotesManual Testing Notes
Manual Testing Notes
 
Manual Testing Material by Durgasoft
Manual Testing Material by DurgasoftManual Testing Material by Durgasoft
Manual Testing Material by Durgasoft
 

Ähnlich wie Qtp test

Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDmitriy Sobko
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31Mahmoud Samir Fayed
 
Fun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksFun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksMongoDB
 
Bigger Stronger Faster
Bigger Stronger FasterBigger Stronger Faster
Bigger Stronger FasterChris Love
 
Samsung WebCL Prototype API
Samsung WebCL Prototype APISamsung WebCL Prototype API
Samsung WebCL Prototype APIRyo Jin
 
Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Docker, Inc.
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingBDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingJohn Ferguson Smart Limited
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210Mahmoud Samir Fayed
 
Event Sourcing - what could go wrong - Devoxx BE
Event Sourcing - what could go wrong - Devoxx BEEvent Sourcing - what could go wrong - Devoxx BE
Event Sourcing - what could go wrong - Devoxx BEAndrzej Ludwikowski
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade ServerlessKatyShimizu
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade ServerlessKatyShimizu
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4.1 book - Part 13 of 31The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4.1 book - Part 13 of 31Mahmoud Samir Fayed
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 

Ähnlich wie Qtp test (20)

Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in Kotlin
 
Qtp day 3
Qtp day 3Qtp day 3
Qtp day 3
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
 
Fun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksFun Teaching MongoDB New Tricks
Fun Teaching MongoDB New Tricks
 
Bigger Stronger Faster
Bigger Stronger FasterBigger Stronger Faster
Bigger Stronger Faster
 
Rhino Mocks
Rhino MocksRhino Mocks
Rhino Mocks
 
Samsung WebCL Prototype API
Samsung WebCL Prototype APISamsung WebCL Prototype API
Samsung WebCL Prototype API
 
Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingBDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210
 
Event Sourcing - what could go wrong - Devoxx BE
Event Sourcing - what could go wrong - Devoxx BEEvent Sourcing - what could go wrong - Devoxx BE
Event Sourcing - what could go wrong - Devoxx BE
 
mobl
moblmobl
mobl
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4.1 book - Part 13 of 31The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4.1 book - Part 13 of 31
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 

Mehr von G.C Reddy

New features in qtp11
New features in qtp11New features in qtp11
New features in qtp11G.C Reddy
 
Software+struc+doc
Software+struc+docSoftware+struc+doc
Software+struc+docG.C Reddy
 
Qtp (advanced)
Qtp (advanced)Qtp (advanced)
Qtp (advanced)G.C Reddy
 
Qtp (basics to advanced)
Qtp (basics to advanced)Qtp (basics to advanced)
Qtp (basics to advanced)G.C Reddy
 
Object Repository
Object RepositoryObject Repository
Object RepositoryG.C Reddy
 
Advanced Qtp
Advanced QtpAdvanced Qtp
Advanced QtpG.C Reddy
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp BookG.C Reddy
 
File System Operations
File System OperationsFile System Operations
File System OperationsG.C Reddy
 
Web Dictionary
Web DictionaryWeb Dictionary
Web DictionaryG.C Reddy
 

Mehr von G.C Reddy (14)

Html
HtmlHtml
Html
 
New features in qtp11
New features in qtp11New features in qtp11
New features in qtp11
 
Software+struc+doc
Software+struc+docSoftware+struc+doc
Software+struc+doc
 
Qtp (advanced)
Qtp (advanced)Qtp (advanced)
Qtp (advanced)
 
Qtp (basics to advanced)
Qtp (basics to advanced)Qtp (basics to advanced)
Qtp (basics to advanced)
 
Object Repository
Object RepositoryObject Repository
Object Repository
 
Advanced Qtp
Advanced QtpAdvanced Qtp
Advanced Qtp
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp Book
 
Qtp Scripts
Qtp ScriptsQtp Scripts
Qtp Scripts
 
File System Operations
File System OperationsFile System Operations
File System Operations
 
Qtp Faq
Qtp FaqQtp Faq
Qtp Faq
 
Qtp Summary
Qtp SummaryQtp Summary
Qtp Summary
 
Qtp Scripts
Qtp ScriptsQtp Scripts
Qtp Scripts
 
Web Dictionary
Web DictionaryWeb Dictionary
Web Dictionary
 

Qtp test

  • 1. Visit: www.gcreddy.com for QTP Information Types of Statements in QTP Test We use different types of statements in QTP Test or Test script i) Declarations a) Declaring Variables Dim strCity, intNum, objExcel, myDate strCity="Hyderabad" intNum=100 myDate=#10/10/2010# Set objExcel=CreateObject("Excel.Application") b) Declaring Constants Const City="Hyderabad" Const Login="text:=Login", Agent="window id:=2001", Password="attached text:=Password:" ii) Comments Ex1: Using Apostrophe (‘) symbol before the Statement 'Creating an Automation Object in Database Connection Class, that can be used to connect to Databases (any Daatabase) Set objConnection=CreateObject("Adodb.Connection") Ex2: Using Rem Command followed by space Rem Creating an Automation Object in FileSystemObject Class, that can be used to perform Operations on Computer File system Rem Using this Automation Object we can work with Folders and Files Set objFSO=CreateObject("Scripting.FileSystemObject") iii) Utility Statements Examples: a) Launching Windows based applications SystemUtil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" Or InvokeApplication "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" b) Launching Web based applications SystemUtil.Run "C:Program FilesInternet ExplorerIEXPLORE.EXE","www.gcreddy.com" c) Closing all decent process G C Reddy (91-9247837478), QTP Trainer,INDIA 1
  • 2. Visit: www.gcreddy.com for QTP Information SystemUtil.CloseDescendentProcesses d) Defining Test Result Reporter.ReportEvent micPass,"Result","Test Passed" Reporter.ReportEvent micFail,"Result","Test Failed" e) Using environment Variables Environment.Value("ProductDir") f) DataTable Operations 'Adding a Sheet to Run-Time DataTable DataTable.AddSheet "Gcreddy" iv) Object Calls Examples: a) Standard Windows Environment Dialog("Login").WinButton("Cancel").Click b) Visual Basic Environment VbWindow("CALCULATOR").VbButton("CLEAR").Click c) Web Environment Browser("Google").Page("Google").Link("Gmail").Click v) Flow Control Statements a) Using If statement If Total=Tickets*Price Then Reporter.ReportEvent micPass,"Res","Total is Correct" Else Reporter.ReportEvent micFail,"Res","Total is InCorrect" End If b) Using Select case Statement Select Case Keyword Case "ln" Result=Login("gcreddy@yahoo.com","abcd") DataTable(7,"TestStep")=Result Case "ca" Close_App() Case "rn" Result=Register("gcreddy2@gmail.com") DataTable(7,"TestStep")=Result G C Reddy (91-9247837478), QTP Trainer,INDIA 2
  • 3. Visit: www.gcreddy.com for QTP Information Case "al" Result=App_Launch() DataTable(7,"TestStep")=Result End Select c) Using For…Next Loop For i=1 to MRowCount Step 1 DataTable.SetCurrentRow(i) ModuleExe=DataTable(3,"Module") If UCase(ModuleExe)="Y" Then ModuleID=DataTable(1,"Module") Next d) Using While…Wend Statement While objRecordset2.EOF=False Wscript.Echo objRecordset2.Fields.Item("DriveName"), _ objRecordset2.Fields.Item("DriveDescription") objRecordSet2.MoveNext Wend e) Using Do While …Loop Do While objRs.EOF=False a=objRs.Fields ("Agent") b=objRs.Fields ("Pwd") myFile.Writeline a &","& b r=r+1 objRs.MoveNext Loop f) Using Do Until …Loop Do Until objRs.EOF a=objRs.Fields ("gcreddy") b=objRs.Fields ("qtp") myFile.Writeline a &","& b r=r+1 objRs.MoveNext Loop g) Using For Each …Next For Each element In x msgbox element Next vi) Function/Action Calls G C Reddy (91-9247837478), QTP Trainer,INDIA 3
  • 4. Visit: www.gcreddy.com for QTP Information a) Function calls Dim myDate myDate=Date Msgbox myDate Msgbox NOW ‘Built-in Function Call Login (“gcreddy”,”mercury”) ‘User defined Function b) Action Calls RunAction "Registration [Orders]", oneIteration vii) Check point statements Window("Flight Reservation").WinEdit("Name:").Check CheckPoint("Name:") viii) Output value statements Window("Flight Reservation").WinButton("Update Order").Output CheckPoint("Update Order") ix) Synchronization point statements Window("Flight Reservation").WinButton("Delete Order").WaitProperty "enabled", True, 30000 x) VB Script statements Examples: a) Synchronization using Wait Statement Wait 10 b) Code Optimization Using With and End With Statements With Dialog("Login") .Activate .WinEdit("Agent Name:").Set "vdfdg" .WinEdit("Password:").SetSecure "4d52b150608f41854dfd1714582004f58c475d84" .WinButton("OK").Click End With c) Defining Private Functions using Private statement Private Function Login(UserId, Password) -------- Statements ---------- ---------- End Function d) Storing Object Reference using Set Statement Set myPage=Browser("QuickTest Professional").Page("QuickTest Professional") G C Reddy (91-9247837478), QTP Trainer,INDIA 4
  • 5. Visit: www.gcreddy.com for QTP Information e) Declaring Variables using Public statement Public strName, intPhNumber ‘************************************************************* With Best Wishes http://www.gcreddy.com/ G C Reddy (91-9247837478), QTP Trainer,INDIA 5