SlideShare una empresa de Scribd logo
1 de 13
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

Más contenido relacionado

La actualidad más candente

Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCAWhymca
 
Getting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net DriverGetting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net DriverDataStax Academy
 
Building .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase LiteBuilding .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase Litegramana
 
Realm: Building a mobile database
Realm: Building a mobile databaseRealm: Building a mobile database
Realm: Building a mobile databaseChristian Melchior
 
Mongo db勉強会20110730
Mongo db勉強会20110730Mongo db勉強会20110730
Mongo db勉強会20110730Akihiro 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 MingRick Copeland
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETTomas 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 ExamplesUser1test
 
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 OperationsMark Needham
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersBen 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 MongoDBMongoDB
 
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 2015StampedeCon
 
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 KorotkovNikolay Samokhvalov
 

La actualidad más candente (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
 

Destacado (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 a 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 4493Azhar 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 pythonLifna C.S
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almostQuinton Sheppard
 
Apache ant
Apache antApache ant
Apache antkoniik
 
コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門潤一 加藤
 
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.6RUDDER
 
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.6Jonathan Clarke
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformationLars Marius Garshol
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptzand3rs
 
Enjoy Munit with Mule
Enjoy Munit with MuleEnjoy Munit with Mule
Enjoy Munit with MuleBui Kiet
 
Accelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderAccelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderDatabricks
 
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 BoltonMiva
 

Similar a 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
 

Más de 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
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Último (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

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