SlideShare a Scribd company logo
QTP Utility Functions – File Operations
             File Creation

     3.      CreateFile "C:","mytextfile.txt","hi how are you?"
     4.      Public Function CreateFile(filpath,filname,filcontent)
     5.            xml_file = filpath & "" & filname
     6.            Dim fileobject, tf
     7.            Set fileobject = CreateObject("Scripting.FileSystemObject")
     8.            Set tf = fileobject.CreateTextFile(xml_file, True)
     9.            tf.Write (filcontent)
     10.           tf.Close
     11.     End Function




1
    © Copyright GlobalLogic 2008
QTP Utility Functions – File Operations
     •     dim oFSO
     •     ' creating the file system object
     •     set oFSO = CreateObject ("Scripting.FileSystemObject")
     •
     •     'Option Explicit
     •     ' *********************************************************************************************
     •     ' Create a new txt file
     •
     •     ' Parameters:
     •     ' FilePath - location of the file and its name
     •     ' *********************************************************************************************
     •     Function CreateFile (FilePath)
     •         ' varibale that will hold the new file object
     •         dim NewFile
     •         ' create the new text ile
     •         set NewFile = oFSO.CreateTextFile(FilePath, True)
     •         set CreateFile = NewFile
     •      End Function
     •
     •     ' *********************************************************************************************
     •     ' Check if a specific file exist
     •
     •     ' Parameters:
     •     ' FilePath - location of the file and its name
     •     ' *********************************************************************************************


2
    © Copyright GlobalLogic 2008
QTP Utility Functions – File Operations
     •     Function CheckFileExists (FilePath)
     •       ' check if file exist
     •       CheckFileExists = oFSO.FileExists(FilePath)
     •     End Function
     •
     •     ' *********************************************************************************************
     •     ' Write data to file
     •
     •     ' Parameters:
     •     ' FileRef - reference to the file
     •     ' str - data to be written to the file
     •     ' *********************************************************************************************
     •     Function WriteToFile (byref FileRef,str)
     •        ' write str to the text file
     •        FileRef.WriteLine(str)
     •     End Function
     •
     •     ' *********************************************************************************************
     •     ' Read line from file
     •
     •     ' Parameters:
     •     ' FileRef - reference to the file
     •     ' *********************************************************************************************




3
    © Copyright GlobalLogic 2008
QTP Utility Functions – File Operations
     •     Function ReadLineFromFile (byref FileRef)
     •       ' read line from text file
     •       ReadLineFromFile = FileRef.ReadLine
     •     End Function
     •
     •     ' *********************************************************************************************
     •     ' Closes an open file.
     •     ' Parameters:
     •     ' FileRef - reference to the file
     •     ' *********************************************************************************************
     •     Function CloseFile (byref FileRef)
     •         FileRef.close
     •     End Function
     •
     •     '*********************************************************************************************
     •     ' Opens a specified file and returns an object that can be used to
     •     ' read from, write to, or append to the file.
     •
     •     ' Parameters:
     •     ' FilePath - location of the file and its name
     •     ' mode options are:
     •     ' ForReading - 1
     •     ' ForWriting - 2
     •     ' ForAppending - 8
     •     ' *********************************************************************************************


4
    © Copyright GlobalLogic 2008
QTP Utility Functions – File Operations
    •     ' *********************************************************************************************
    •     Function OpenFile (FilePath,mode)
    •         ' open the txt file and retunr the File object
    •         set OpenFile = oFSO.OpenTextFile(FilePath, mode, True)
    •     End Function
    •
    •     ' *********************************************************************************************
    •     ' Copy a File

    •     ' Parameters:
    •     ' FilePathSource - location of the source file and its name
    •     ' FilePathDest - location of the destination file and its name
    •     ' *********************************************************************************************
    •     Sub FileCopy ( FilePathSource,FilePathDest)
    •         ' copy source file to destination file
    •         oFSO.CopyFile FilePathSource, FilePathDest
    •     End Sub
    •
    •     ' *********************************************************************************************
    •     ' Delete a file.
    •
    •     ' Parameters:
    •     ' FilePath - location of the file to be deleted
    •     ' *********************************************************************************************
    •     Sub FileDelete ( FilePath)
    •         ' copy source file to destination file
    •         oFSO.DeleteFile ( FilePath)
    •     End Sub
5
    © Copyright GlobalLogic 2008
QTP Utility Functions – File Operations
     •     ' ************** Example of calling the file functions **********************
     •     FilePath1 = "D:tempFSOtxt1.txt"
     •     FilePath2 = "D:tempFSOtxt2.txt"
     •     FilePathDiff = "D:tempFSOtxt_diff.txt"
     •
     •     FilePath = "D:tempFSOtxt.txt"
     •
     •     set fold = FolderCreate ( "D:tempFSOnew")
     •     set f = OpenFile(FilePath,8)
     •     ' = WriteToFile(f,"test line")
     •     d = CloseFile(f)

     •     set f = CreateFile(FilePath)
     •
     •     Fexist= CheckFileExists(FilePath)
     •     d = WriteToFile(f,"first line")
     •     d = WriteToFile(f,"second line")
     •      d = CloseFile(f)
     •     FileCopy "D:tempFSOtxt.txt","D:tempFSOtxt1.txt"
     •     FileDelete "D:tempFSOtxt1.txt"




6
    © Copyright GlobalLogic 2008
QTP Utility Functions –                      Excel Sheet Operations


    •     Function ReadExcelData(xlFile, sheetName, columnName, rowNum)
    •
    •              ' Initializing the variables
    •              varSheetName = sheetName
    •              varColumnName = columnName
    •              varRowNum = rowNum
    •
    •            Set objExcel = CreateObject("Excel.Application")
    •            objExcel.WorkBooks.Open xlFile
    •            Set objSheet = objExcel.ActiveWorkbook.Worksheets(varSheetName)
    •            rows = objSheet.Range("A1").CurrentRegion.Rows.Count
    •        columns = objSheet.Range("A1").CurrentRegion.Columns.Count
    •            For currCol = 1 to columns
    •                    If objSheet.Cells(1,currCol).Value = varColumnName then
    •                            ReadExcelData = objSheet.Cells(varRowNum+1,currCol).Value
    •                            currCol = columns
    •                    end if
    •            Next
    •
    •           objExcel.ActiveWorkbook.Close
    •           objExcel.Application.Quit
    •           Set objSheet = nothing
    •           Set objExcel = nothing
    •     End Function
7
    © Copyright GlobalLogic 2008
QTP Utility Functions – Email Operations

         •     SendMail “rajat.gupta@globallogic.com","hi","how r u",""

         •     Function SendMail(SendTo, Subject, Body, Attachment)

         •         Set ol=CreateObject("Outlook.Application")
         •         Set Mail=ol.CreateItem(0)
         •         Mail.to=SendTo
         •         Mail.Subject=Subject
         •         Mail.Body=Body
         •         If (Attachment <> "") Then

         •             Mail.Attachments.Add(Attachment)

         •         End If
         •         Mail.Send
         •         ol.Quit
         •         Set Mail = Nothing
         •         Set ol = Nothing

         •     End Function




8
    © Copyright GlobalLogic 2008
QTP Utility Functions – Timed                           Msg-Box

     •     MsgBoxTimeout (“Sample Text”,”Timed MsgBox”, 10)

     •     Public Sub MsgBoxTimeout (Text, Title, TimeOut)
            Set WshShell = CreateObject("WScript.Shell")
            WshShell.Popup Text, TimeOut, Title
     •     End Sub




9
    © Copyright GlobalLogic 2008
QTP Utility Functions – Keystroke Functions
      •     'An example that presses a key using DeviceReplay.
      •     Set obj = CreateObject("Mercury.DeviceReplay")

      •     Window("Notepad").Activate

      •     obj.PressKey 63




10
     © Copyright GlobalLogic 2008
QTP Utility Functions – keyboard Values




11
     © Copyright GlobalLogic 2008
QTP Utility Functions – System Operations
      •        Running and Closing Applications Programmatically
      •        Syntax:
      •        SystemUtil.Run “file, [params], [dir] “

      •        Example:
      •        SystemUtil.Run “notepad.exe myfile.txt “




12
     © Copyright GlobalLogic 2008
QTP Utility Functions – Clipboard Objects
       The object has the same methods as the Clipboard object available
        in Visual Basic:
                  Clear
                  GetData
                  GetFormat
                  GetText
                  SetData
                  SetText
      •      Set cb = CreateObject("Mercury.Clipboard")
            cb.Clear
            cb.SetText "TEST"
            MsgBox cb.GetText




13
     © Copyright GlobalLogic 2008

More Related Content

What's hot

Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
Whymca
 
Getting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net DriverGetting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net Driver
DataStax Academy
 
Building .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase LiteBuilding .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase Lite
gramana
 
Realm: Building a mobile database
Realm: Building a mobile databaseRealm: Building a mobile database
Realm: Building a mobile database
Christian Melchior
 
Mongo db勉強会20110730
Mongo db勉強会20110730Mongo db勉強会20110730
Mongo db勉強会20110730
Akihiro Okuno
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
Norberto Leite
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
Tomas Jansson
 
Replacing Oracle with MongoDB for a templating application at the Bavarian go...
Replacing Oracle with MongoDB for a templating application at the Bavarian go...Replacing Oracle with MongoDB for a templating application at the Bavarian go...
Replacing Oracle with MongoDB for a templating application at the Bavarian go...
Comsysto Reply GmbH
 
Qtp Imp Script Examples
Qtp Imp Script ExamplesQtp Imp Script Examples
Qtp Imp Script Examples
User1test
 
Green dao
Green daoGreen dao
Green dao
彥彬 洪
 
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and OperationsNeo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Mark Needham
 
Latinoware
LatinowareLatinoware
Latinoware
kchodorow
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET Developers
Ben van Mol
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
MongoDB
 
Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015
StampedeCon
 
Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)
MongoDB
 
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander KorotkovPostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov
Nikolay Samokhvalov
 
greenDAO
greenDAOgreenDAO
greenDAO
Mu Chun Wang
 
Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0
Victor Coustenoble
 

What's hot (20)

Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
Getting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net DriverGetting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net Driver
 
Building .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase LiteBuilding .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase Lite
 
Realm: Building a mobile database
Realm: Building a mobile databaseRealm: Building a mobile database
Realm: Building a mobile database
 
Mongo db勉強会20110730
Mongo db勉強会20110730Mongo db勉強会20110730
Mongo db勉強会20110730
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
Replacing Oracle with MongoDB for a templating application at the Bavarian go...
Replacing Oracle with MongoDB for a templating application at the Bavarian go...Replacing Oracle with MongoDB for a templating application at the Bavarian go...
Replacing Oracle with MongoDB for a templating application at the Bavarian go...
 
Qtp Imp Script Examples
Qtp Imp Script ExamplesQtp Imp Script Examples
Qtp Imp Script Examples
 
Green dao
Green daoGreen dao
Green dao
 
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and OperationsNeo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
 
Latinoware
LatinowareLatinoware
Latinoware
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET Developers
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015
 
Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)
 
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander KorotkovPostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov
PostgreSQL Moscow Meetup - September 2014 - Oleg Bartunov and Alexander Korotkov
 
greenDAO
greenDAOgreenDAO
greenDAO
 
Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0
 

Viewers also liked

18 octubre2007 borinbizkarra
18 octubre2007 borinbizkarra18 octubre2007 borinbizkarra
18 octubre2007 borinbizkarra
HUGO ARAUJO
 
120 marketing-stats-charts-and-graphs
120 marketing-stats-charts-and-graphs120 marketing-stats-charts-and-graphs
120 marketing-stats-charts-and-graphs
Consultora de Marketing Digital
 
Gl qtp day 1 & 2
Gl qtp   day 1 & 2Gl qtp   day 1 & 2
Gl qtp day 1 & 2
Pragya Rastogi
 
70562-Dumps
70562-Dumps70562-Dumps
70562-Dumps
Pragya Rastogi
 
70 433
70 43370 433
32916
3291632916
A1
A1A1
How to-segment-integrate-your-emails-fin
How to-segment-integrate-your-emails-finHow to-segment-integrate-your-emails-fin
How to-segment-integrate-your-emails-fin
Consultora de Marketing Digital
 

Viewers also liked (9)

18 octubre2007 borinbizkarra
18 octubre2007 borinbizkarra18 octubre2007 borinbizkarra
18 octubre2007 borinbizkarra
 
120 marketing-stats-charts-and-graphs
120 marketing-stats-charts-and-graphs120 marketing-stats-charts-and-graphs
120 marketing-stats-charts-and-graphs
 
Gl qtp day 1 & 2
Gl qtp   day 1 & 2Gl qtp   day 1 & 2
Gl qtp day 1 & 2
 
70562-Dumps
70562-Dumps70562-Dumps
70562-Dumps
 
70 433
70 43370 433
70 433
 
32916
3291632916
32916
 
Index Grey (1)
Index Grey (1)Index Grey (1)
Index Grey (1)
 
A1
A1A1
A1
 
How to-segment-integrate-your-emails-fin
How to-segment-integrate-your-emails-finHow to-segment-integrate-your-emails-fin
How to-segment-integrate-your-emails-fin
 

Similar to Gl qtp day 3 2

Qtp Training Deepti 4 Of 4493
Qtp Training Deepti 4 Of 4493Qtp Training Deepti 4 Of 4493
Qtp Training Deepti 4 Of 4493
Azhar Satti
 
Jaffle: managing processes and log messages of multiple applications in devel...
Jaffle: managing processes and log messages of multiple applicationsin devel...Jaffle: managing processes and log messages of multiple applicationsin devel...
Jaffle: managing processes and log messages of multiple applications in devel...
Masaki Yatsu
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
Lifna C.S
 
JS Essence
JS EssenceJS Essence
JS Essence
Uladzimir Piatryka
 
занятие8
занятие8занятие8
занятие8
Oleg Parinov
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
Quinton Sheppard
 
Database training for developers
Database training for developersDatabase training for developers
Database training for developers
Bhaveshkumar Thakkar
 
Apache ant
Apache antApache ant
Apache ant
koniik
 
コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門
潤一 加藤
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6
Jonathan Clarke
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6
RUDDER
 
Apachepoitutorial
ApachepoitutorialApachepoitutorial
Apachepoitutorial
Srikrishna k
 
Files and streams
Files and streamsFiles and streams
Files and streams
Pranali Chaudhari
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
Lars Marius Garshol
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
zand3rs
 
Apache poi tutorial
Apache poi tutorialApache poi tutorial
Apache poi tutorial
Ramakrishna kapa
 
File mangement
File mangementFile mangement
File mangement
Jigarthacker
 
Enjoy Munit with Mule
Enjoy Munit with MuleEnjoy Munit with Mule
Enjoy Munit with Mule
Bui Kiet
 
Accelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderAccelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks Autoloader
Databricks
 
WorkFlow: An Inquiry Into Productivity by Timothy Bolton
WorkFlow:  An Inquiry Into Productivity by Timothy BoltonWorkFlow:  An Inquiry Into Productivity by Timothy Bolton
WorkFlow: An Inquiry Into Productivity by Timothy Bolton
Miva
 

Similar to Gl qtp day 3 2 (20)

Qtp Training Deepti 4 Of 4493
Qtp Training Deepti 4 Of 4493Qtp Training Deepti 4 Of 4493
Qtp Training Deepti 4 Of 4493
 
Jaffle: managing processes and log messages of multiple applications in devel...
Jaffle: managing processes and log messages of multiple applicationsin devel...Jaffle: managing processes and log messages of multiple applicationsin devel...
Jaffle: managing processes and log messages of multiple applications in devel...
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
 
JS Essence
JS EssenceJS Essence
JS Essence
 
занятие8
занятие8занятие8
занятие8
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
Database training for developers
Database training for developersDatabase training for developers
Database training for developers
 
Apache ant
Apache antApache ant
Apache ant
 
コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6
 
Apachepoitutorial
ApachepoitutorialApachepoitutorial
Apachepoitutorial
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
 
Apache poi tutorial
Apache poi tutorialApache poi tutorial
Apache poi tutorial
 
File mangement
File mangementFile mangement
File mangement
 
Enjoy Munit with Mule
Enjoy Munit with MuleEnjoy Munit with Mule
Enjoy Munit with Mule
 
Accelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderAccelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks Autoloader
 
WorkFlow: An Inquiry Into Productivity by Timothy Bolton
WorkFlow:  An Inquiry Into Productivity by Timothy BoltonWorkFlow:  An Inquiry Into Productivity by Timothy Bolton
WorkFlow: An Inquiry Into Productivity by Timothy Bolton
 

More from Pragya Rastogi

Gl android platform
Gl android platformGl android platform
Gl android platform
Pragya Rastogi
 
Qtp questions
Qtp questionsQtp questions
Qtp questions
Pragya Rastogi
 
Qtp not just for gui anymore
Qtp   not just for gui anymoreQtp   not just for gui anymore
Qtp not just for gui anymore
Pragya Rastogi
 
Qtp tutorial
Qtp tutorialQtp tutorial
Qtp tutorial
Pragya Rastogi
 
Qtp4 bpt
Qtp4 bptQtp4 bpt
Qtp4 bpt
Pragya Rastogi
 
Get ro property outputting value
Get ro property outputting valueGet ro property outputting value
Get ro property outputting value
Pragya Rastogi
 
Bp ttutorial
Bp ttutorialBp ttutorial
Bp ttutorial
Pragya Rastogi
 
Gl istqb testing fundamentals
Gl istqb testing fundamentalsGl istqb testing fundamentals
Gl istqb testing fundamentals
Pragya Rastogi
 
Gl scrum testing_models
Gl scrum testing_modelsGl scrum testing_models
Gl scrum testing_models
Pragya Rastogi
 
My Sql concepts
My Sql conceptsMy Sql concepts
My Sql concepts
Pragya Rastogi
 
Oops
OopsOops
Java programming basics
Java programming basicsJava programming basics
Java programming basics
Pragya Rastogi
 
70433 Dumps DB
70433 Dumps DB70433 Dumps DB
70433 Dumps DB
Pragya Rastogi
 
70562 (1)
70562 (1)70562 (1)
70562 (1)
Pragya Rastogi
 
70 562
70 56270 562
Mobile testingartifacts
Mobile testingartifactsMobile testingartifacts
Mobile testingartifacts
Pragya Rastogi
 
GL_Web application testing using selenium
GL_Web application testing using seleniumGL_Web application testing using selenium
GL_Web application testing using selenium
Pragya Rastogi
 
Gl qtp day 3 1
Gl qtp day 3   1Gl qtp day 3   1
Gl qtp day 3 1
Pragya Rastogi
 

More from Pragya Rastogi (18)

Gl android platform
Gl android platformGl android platform
Gl android platform
 
Qtp questions
Qtp questionsQtp questions
Qtp questions
 
Qtp not just for gui anymore
Qtp   not just for gui anymoreQtp   not just for gui anymore
Qtp not just for gui anymore
 
Qtp tutorial
Qtp tutorialQtp tutorial
Qtp tutorial
 
Qtp4 bpt
Qtp4 bptQtp4 bpt
Qtp4 bpt
 
Get ro property outputting value
Get ro property outputting valueGet ro property outputting value
Get ro property outputting value
 
Bp ttutorial
Bp ttutorialBp ttutorial
Bp ttutorial
 
Gl istqb testing fundamentals
Gl istqb testing fundamentalsGl istqb testing fundamentals
Gl istqb testing fundamentals
 
Gl scrum testing_models
Gl scrum testing_modelsGl scrum testing_models
Gl scrum testing_models
 
My Sql concepts
My Sql conceptsMy Sql concepts
My Sql concepts
 
Oops
OopsOops
Oops
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
70433 Dumps DB
70433 Dumps DB70433 Dumps DB
70433 Dumps DB
 
70562 (1)
70562 (1)70562 (1)
70562 (1)
 
70 562
70 56270 562
70 562
 
Mobile testingartifacts
Mobile testingartifactsMobile testingartifacts
Mobile testingartifacts
 
GL_Web application testing using selenium
GL_Web application testing using seleniumGL_Web application testing using selenium
GL_Web application testing using selenium
 
Gl qtp day 3 1
Gl qtp day 3   1Gl qtp day 3   1
Gl qtp day 3 1
 

Recently uploaded

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 

Recently uploaded (20)

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 

Gl qtp day 3 2

  • 1. QTP Utility Functions – File Operations  File Creation 3. CreateFile "C:","mytextfile.txt","hi how are you?" 4. Public Function CreateFile(filpath,filname,filcontent) 5. xml_file = filpath & "" & filname 6. Dim fileobject, tf 7. Set fileobject = CreateObject("Scripting.FileSystemObject") 8. Set tf = fileobject.CreateTextFile(xml_file, True) 9. tf.Write (filcontent) 10. tf.Close 11. End Function 1 © Copyright GlobalLogic 2008
  • 2. QTP Utility Functions – File Operations • dim oFSO • ' creating the file system object • set oFSO = CreateObject ("Scripting.FileSystemObject") • • 'Option Explicit • ' ********************************************************************************************* • ' Create a new txt file • • ' Parameters: • ' FilePath - location of the file and its name • ' ********************************************************************************************* • Function CreateFile (FilePath) • ' varibale that will hold the new file object • dim NewFile • ' create the new text ile • set NewFile = oFSO.CreateTextFile(FilePath, True) • set CreateFile = NewFile • End Function • • ' ********************************************************************************************* • ' Check if a specific file exist • • ' Parameters: • ' FilePath - location of the file and its name • ' ********************************************************************************************* 2 © Copyright GlobalLogic 2008
  • 3. QTP Utility Functions – File Operations • Function CheckFileExists (FilePath) • ' check if file exist • CheckFileExists = oFSO.FileExists(FilePath) • End Function • • ' ********************************************************************************************* • ' Write data to file • • ' Parameters: • ' FileRef - reference to the file • ' str - data to be written to the file • ' ********************************************************************************************* • Function WriteToFile (byref FileRef,str) • ' write str to the text file • FileRef.WriteLine(str) • End Function • • ' ********************************************************************************************* • ' Read line from file • • ' Parameters: • ' FileRef - reference to the file • ' ********************************************************************************************* 3 © Copyright GlobalLogic 2008
  • 4. QTP Utility Functions – File Operations • Function ReadLineFromFile (byref FileRef) • ' read line from text file • ReadLineFromFile = FileRef.ReadLine • End Function • • ' ********************************************************************************************* • ' Closes an open file. • ' Parameters: • ' FileRef - reference to the file • ' ********************************************************************************************* • Function CloseFile (byref FileRef) • FileRef.close • End Function • • '********************************************************************************************* • ' Opens a specified file and returns an object that can be used to • ' read from, write to, or append to the file. • • ' Parameters: • ' FilePath - location of the file and its name • ' mode options are: • ' ForReading - 1 • ' ForWriting - 2 • ' ForAppending - 8 • ' ********************************************************************************************* 4 © Copyright GlobalLogic 2008
  • 5. QTP Utility Functions – File Operations • ' ********************************************************************************************* • Function OpenFile (FilePath,mode) • ' open the txt file and retunr the File object • set OpenFile = oFSO.OpenTextFile(FilePath, mode, True) • End Function • • ' ********************************************************************************************* • ' Copy a File • ' Parameters: • ' FilePathSource - location of the source file and its name • ' FilePathDest - location of the destination file and its name • ' ********************************************************************************************* • Sub FileCopy ( FilePathSource,FilePathDest) • ' copy source file to destination file • oFSO.CopyFile FilePathSource, FilePathDest • End Sub • • ' ********************************************************************************************* • ' Delete a file. • • ' Parameters: • ' FilePath - location of the file to be deleted • ' ********************************************************************************************* • Sub FileDelete ( FilePath) • ' copy source file to destination file • oFSO.DeleteFile ( FilePath) • End Sub 5 © Copyright GlobalLogic 2008
  • 6. QTP Utility Functions – File Operations • ' ************** Example of calling the file functions ********************** • FilePath1 = "D:tempFSOtxt1.txt" • FilePath2 = "D:tempFSOtxt2.txt" • FilePathDiff = "D:tempFSOtxt_diff.txt" • • FilePath = "D:tempFSOtxt.txt" • • set fold = FolderCreate ( "D:tempFSOnew") • set f = OpenFile(FilePath,8) • ' = WriteToFile(f,"test line") • d = CloseFile(f) • set f = CreateFile(FilePath) • • Fexist= CheckFileExists(FilePath) • d = WriteToFile(f,"first line") • d = WriteToFile(f,"second line") • d = CloseFile(f) • FileCopy "D:tempFSOtxt.txt","D:tempFSOtxt1.txt" • FileDelete "D:tempFSOtxt1.txt" 6 © Copyright GlobalLogic 2008
  • 7. QTP Utility Functions – Excel Sheet Operations • Function ReadExcelData(xlFile, sheetName, columnName, rowNum) • • ' Initializing the variables • varSheetName = sheetName • varColumnName = columnName • varRowNum = rowNum • • Set objExcel = CreateObject("Excel.Application") • objExcel.WorkBooks.Open xlFile • Set objSheet = objExcel.ActiveWorkbook.Worksheets(varSheetName) • rows = objSheet.Range("A1").CurrentRegion.Rows.Count • columns = objSheet.Range("A1").CurrentRegion.Columns.Count • For currCol = 1 to columns • If objSheet.Cells(1,currCol).Value = varColumnName then • ReadExcelData = objSheet.Cells(varRowNum+1,currCol).Value • currCol = columns • end if • Next • • objExcel.ActiveWorkbook.Close • objExcel.Application.Quit • Set objSheet = nothing • Set objExcel = nothing • End Function 7 © Copyright GlobalLogic 2008
  • 8. QTP Utility Functions – Email Operations • SendMail “rajat.gupta@globallogic.com","hi","how r u","" • Function SendMail(SendTo, Subject, Body, Attachment) • Set ol=CreateObject("Outlook.Application") • Set Mail=ol.CreateItem(0) • Mail.to=SendTo • Mail.Subject=Subject • Mail.Body=Body • If (Attachment <> "") Then • Mail.Attachments.Add(Attachment) • End If • Mail.Send • ol.Quit • Set Mail = Nothing • Set ol = Nothing • End Function 8 © Copyright GlobalLogic 2008
  • 9. QTP Utility Functions – Timed Msg-Box • MsgBoxTimeout (“Sample Text”,”Timed MsgBox”, 10) • Public Sub MsgBoxTimeout (Text, Title, TimeOut) Set WshShell = CreateObject("WScript.Shell") WshShell.Popup Text, TimeOut, Title • End Sub 9 © Copyright GlobalLogic 2008
  • 10. QTP Utility Functions – Keystroke Functions • 'An example that presses a key using DeviceReplay. • Set obj = CreateObject("Mercury.DeviceReplay") • Window("Notepad").Activate • obj.PressKey 63 10 © Copyright GlobalLogic 2008
  • 11. QTP Utility Functions – keyboard Values 11 © Copyright GlobalLogic 2008
  • 12. QTP Utility Functions – System Operations • Running and Closing Applications Programmatically • Syntax: • SystemUtil.Run “file, [params], [dir] “ • Example: • SystemUtil.Run “notepad.exe myfile.txt “ 12 © Copyright GlobalLogic 2008
  • 13. QTP Utility Functions – Clipboard Objects  The object has the same methods as the Clipboard object available in Visual Basic:  Clear  GetData  GetFormat  GetText  SetData  SetText • Set cb = CreateObject("Mercury.Clipboard") cb.Clear cb.SetText "TEST" MsgBox cb.GetText 13 © Copyright GlobalLogic 2008