SlideShare uma empresa 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque (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
 

Semelhante 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
 

Semelhante 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
 

Mais 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

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

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