Pages

Tuesday, March 1

Launch QTP with QC Connection and Add-ins using vbscript

Suppose you are working on an Java application and you are using Java add-in and say Oracle add-in. Also, you are running your test from QC. One way to do this is simply open QTP, select required add-ins, connect with QTP manually and then open your test by browsing to its location. This'll take about 10 mins, i beleive.
Yeah...!!! But what can I do?

Well, you can do a lot! In this post we'll see how to launch qtp with all required settings, add-ins, and connection with QC, and even open a particular test by default.

Everything is done in just one click... Sounds great??  Okie... here we go...!

Set App = CreateObject("QuickTest.Application") ' Create the Application object
App.SetActiveAddins Array("Web", "Java", "Oracle") 'Set the required Add-Ins
App.Launch ' Start QuickTest
App.Visible = True ' Make the QuickTest application visible
App.New ' Open a new test
'App.Open "D:\John\" '-  use this if you want to open existing test
If Not App.TDConnection.IsConnected Then
    App.TDConnection.Connect "http://<server url>","<domain name>","<project name>","<user name>","<password>",False ' remove <> brackets
End If
App.Options.Run.ViewResults = False
App.Test.Actions("Action1").ObjectRepositories.Add "[QualityCenter] Subject\john\Repository\Rep.tsr"
App.Test.Settings.Resources.Libraries.Add "[QualityCenter] Subject\john\Repository\Lib.vbs"
'App.Test.Actions("Action1").SetScript "'TestCaseId:  "&vbCrlf&"'TestCaseName:  "&vbCrlf&"'Description:  "&vbCrlf&"'Created By:  John"&vbCrlf&vbCrlf&vbCrlf&"'*******************************Prerequisites********************************"&vbCrlf &"'Application should be open and login"&vbCrlf &"'*******************************************************************************"

Set App = Nothing ' Release the Application object

In case of any queries, please leave your comments.

3 comments:

  1. Getting error "This operation can be performed only before the application start" for line2.

    ReplyDelete
  2. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete