Ultimatetimepass logo

  • Home
    • QuickTest
      • Webbased
        • Close Opened Browsers Except QC
        • open/ launch a new session of IE
        • GET COUNT AND NAMES OF ALL OPEN BROWSERS
        • Get No of links in a page- Descriptive programming
        • Function to click on menu (Mimic the user action)
        • Function to display type ahead list in a dropdown
        • Drag and Drop the files into application
      • XML
        • Read XML
        • Create XML
        • Merge 2 XML
      • Excel
        • Read Excel using ADODB connection
        • Delete Columns from excel sheet
        • Delete Rows From excel sheet
        • Excel Sorting
        • Save as a Password Protected Excel sheet
        • Open a Password Protected excel and save as unprotected
        • Find a value in Excel Sheet
        • Create and update a excel File at given path
        • To Query a Excel Sheet as a database
      • VBScript
        • To type keyboard input onto the open window
        • Send or Type a key on the application using wscript.shell
        • Set a default Printer
        • To Verify an Application launch
        • Verify and delete a file to a specific location
        • Create MS Word, Edit and Print a blank page
        • Create a MS Access(.mdb) database file
        • Import a XML file to MS Access database
        • Connect to SQL Server
        • Connect to MS Access DB
        • Create a Text File at given path
        • Read a text file and store data in a variable
        • Get number of pages in pdf
    • VBScript
      • Generate a chart in excel
      • Map a netwrok drive
      • Retrieve computer operating system name
      • Kill a task manager process
      • Make a message alert with ding sound using Microsoft Office assistant popup
      • Include a functional library or any other VBscript code available in your current script
    • TestPartner
      • Launch TestPartner from VBscript or any other tool
    • Software Risk Management
    • Software Testing Estimation Techniques
    • Capability Maturity Model Integration (CMMI)
    • Test Policy, Test strategy ,Test Plan
    • Load Testing
      • Load Test Test Plan
      • Performace, Load and Stress test
  • Contact US
  • Privacy Policy

Home

Welcome to Automation section of Ultimate timepass

  • Print
  • Email

Here you can find lots of day to day useful automation code samples mainly related to VB script, VBA , Quicktest Professional and Test Partner.

You can also find good collection of automation code related to integration with various QA automation tools like Quality center, ALM and Microsoft test management etc. 

 

Please select your desire section from below links.

Article related to Quicktest Professional (QTP) Web based automation:-

  • Close Opened Browsers Except QC
  • GET COUNT AND NAMES OF ALL OPEN BROWSERS
  • Get No of links in a page- Descriptive programming
  • Drag and Drop the files into application
  • Function to click on menu (Mimic the user action)
  • Function to display type ahead list in a dropdown

Article related to Excel automation with Quicktest Professional (QTP). These code could be used VBA applications also.

  •  Read Excel using ADODB connection
  • To Delete Columns from a Excel sheet
  • Delete Rows From excel sheet
  • Excel sorting
  • Save as a Password Protected Excel sheet
  • Open a Password Protected excel and save as unprotected
  • Find a value in Excel Sheet
  • Create and update a excel File at given path
  • To Query a Excel Sheet as a database

 

Articles related to XML automation with Quicktest Professional (QTP)

  • Read XML (Dotnet Factory)
  • Create XML (Dotnet Factory)
  • Merge 2 XML (Dotnet Factory)

 

Articles related to VB script automation with Quicktest Professional (QTP)

  • To type keyboard input onto the open window
  • Set a default Printer
  • To Verify an Application launch
  • Create MS Word, Edit and Print a blank page
  • Create a MS Access(.mdb) database file
  • Import a XML file to MS Access database
  • Connect to SQL Server
  • Connect to MS Access DB
  • Create a Text File at given path
  • Read a text file and store data in a variable
  • Get number of pages in pdf

Connect to SQL Server

  • Print
  • Email


Connection string fro SQL Server, use following code:
Steps:

1) Create an ADODB connection  with provider as "sqloledb"

2) Open database connection

Code:

'Connect to SQL Server
'==============================================
Function Create_SQL_Connection(DataSource,Ini_catalog)
'1) Create an ADODB connection  with provider as "sqloledb"'
set SQLcon= CreateObject( "ADODB.Connection")
SQLcon.ConnectionString = "Provider='sqloledb';Data Source='" & DataSource & "';" & _
          "Initial Catalog='" & Ini_catalog & " ';Trusted_Connection=YES"
'2) Open database connection'
SQLcon.Open
End Function

Make a message alert with ding sound using Microsoft Office assistant popup

  • Print
  • Email


Make a message alert with ding sound using Microsoft Office assistant popup, use following code:
Code:

strAgentName = "MERLIN"
strAgentPath = "C:\Windows\Msagent\Chars\" & strAgentName & ".acs"
Set objAgent = CreateObject("Agent.Control.2")

objAgent.Connected = TRUE
objAgent.Characters.Load strAgentName, strAgentPath
Set objPeter = objAgent.Characters.Character(strAgentName)

objPeter.MoveTo 500,300
objPeter.Show

objPeter.Play "GetAttention"
objPeter.Play "GetAttentionReturn"

objPeter.Speak("You got a message, script provided by Automation.ultimatetimepass.com")

Wscript.Sleep 2000

Set objAction= objPeter.Hide

Do While objPeter.Visible = True
Wscript.Sleep 250
Loop

Kill a task manager process

  • Print
  • Email


To Kill a task manager process , use following code:
Steps:
1) Get an object from winmgmts root\CIMV2

2) Execute SQL to retrieve all process from process

3) Kill all process

Code:

 Dim objWMIService, colItems,OSname,strComputer
 
          strComputer = "."
          strProcessToKill="Winword.exe"
'1) Get an object from winmgmts root\CIMV2'         
          Set objWMIService = GetObject("winmgmts:" _
              & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'2) Execute SQL to retrieve all process from process             
          Set colProcessList = objWMIService.ExecQuery _
              ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")

'3) Kill all process'
          For Each objProcess in colProcessList
              objProcess.Terminate()
          Next

Page 1 of 2

  • Start
  • Prev
  • 1
  • 2
  • Next
  • End