Does QTP support Java Script also. Which is one is
preferrable for QTP, VB script or Java script

Answer Posted / govardhan palla



Well We can use VB Script and Java Script and Shell Script
in QTP Tool. But don’t go for other than VB Script. Why is
it so means please go through below..

Please run this script in QTP Tool which is in Java Script
------------------------------------------------------------
---
Setting.Item('DefaultTimeOut') = 100;
Print ('Dummy Text');

try{
Print('Trying to click on a non-existent window');
//try to click on a window which never exists
Window('hwnd:=-1').Click;
}
catch(err)
{
Print('Some error occurred while clicking the window
object - ' + err.description);
}
finally
{
Print('Phew! Finally we are here');
}

Print(Testing is Great :) Isn\'t it?');

------------------------------------------------------------
---
The above I’ve written some piece of code is on JScipt.

But prior to this we need to get idea about why we are
going to use VBScirpt in QTP and why don’t we use other
than that like C#, HTML, C, C++, SQL and so on..

Here the thing is like QTP tool itself having some library
supporting files which call it as a DLL files. Those DLL
files will provide some methods/classes to the tool to get
connection and interface to the object. Hence by taking the
help from those DLL files (Methods/functions/Classes) QTP
will perform any action.

We no need to bother about those DLL files until we are
doing normal testing on VB/Web applications by selecting
addins VB,Web, Active-X. If suppose if we want to testing
on Oracle Applications HRMS/Finance or Sieble or Delphi or
some other application then we make sure to Addins are
available or not in QTP Tool at the time of testing. Hence
if we’ve add-ins in QTP Tool, those addins will provide
methods/functions/classes to QTP tool to perform any action
on the above said applications.

Let us take a simple example like we need to post a Bug in
to Quality Center by running QTP Script(without recording
the script like open the Quality Center and post the bug
manually). For that we need to first create a object by
using “Set tdc = CreateObject("TDApiOle80.TDConnection")”
method.
Once object get created then it will get interface to that
application and based object methods we can write our
script to our own way. You can see rest of things in below
written code..

'###########################################################
############
'#Function ID/Name :Adding_Bugs_To_QC
'#Function Description : This function is used to Add a
new Bug in to Quality Center
'#Function Logic :The function will get
connection witth Quality Center for respective domain,
project with appropriate user id and pwd and
it will enter for particular project bugfactory and add a
new bug in to QC

'#Author :
Govardhan Palla
'#Date : 15-Jan-
2009
'#Version : 1.0
'#Version History : None
'###########################################################
############

Function Add_Bugs_To_QC ( )
Dim tdc
Dim attachFact, attachObj
Dim server, Domain, Project, UName, PWD
Dim FileName, CPath
Set tdc = CreateObject
("TDApiOle80.TDConnection")
server = "http://10.42.63.34:8080/qcbin"
tdc.InitConnectionEx server

'QCConnection.login “<username>”, “<password>”
UName = "admin"
PWD = "admin"
tdc.login UName, PWD
' DEFAULT = Domain, QualityCenter_Demo =
Project
Domain = "Migration"
Project = "Migration_Project2"
tdc.Connect Domain, Project
If tdc.Connected Then
MsgBox "Connected to: " + Server + chr (10)+ "ServerName:"
+ tdc.ServerName + chr (10) + "Domain Name:" + Domain +
chr (10)+ "Project:" + Project
Else
MsgBox("Not
Connected")
End If
'Add a new, empty defect
Set bug = tdc.BugFactory.AddItem (Nothing)
bug.field("BG_SUMMARY") = defect_summary '"test adding a
new defect from QTP as well as automatic e-mail
functionality"
bug.field ("BG_STATUS") = "New" '--Default
bug.field ("BG_DETECTED_BY") = detected_by
bug.field ("BG_DETECTION_DATE") = date() 'Default to
current date
bug.field ("BG_DESCRIPTION") = "Requirement = '"&req&"' -
"&defect_desc'"This is a test entry from automation,
QuickTest Pro. The actual result did not meet the expected
result. The Analyst, Developer (Assigned To person) and
Tester (Deteted By person) should get an email of this
defect automatically."
bug.field ("BG_RESPONSIBLE") =
assign_to '"GovardhanPalla" 'Assigned To field
'These are user defined fields
bug.field ("BG_USER_02") = analyst'Analyst field
bug.field ("BG_USER_04") = "Testing" 'Introduced By field --
DEFAULT
bug.field ("BG_USER_05") = req'Requirements field
bug.field ("BG_USER_03") ="Automation" 'Found In field -
'Default
'install_date = DateAdd("d",30,date())
bug.field ("BG_USER_06") = install_date 'Install Date field
bug.Post 'commit to creating defect
'Clean and and release resources
Set BugFactory = Nothing
Set bug = Nothing
'###########################################################
############

The above written code is typically in VB Script. To post a
bug in QC J Script or Shell Script or than VB Script won’t
support with QTP environment. We can post the QC bug by
using Visual Studio environment by using VB or C# or rest
of languages and that is beyond our boundaries as well.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the automation metrice in your project?

1709


What is the virtual object?

636


To which environments does quicktest professional supports?

533


What are advantages of test automation?

663


How to capture all the data of a webtable, weblist and combolist using QTP?

2850






How do you create regression test packs?

607


What are the different ways to invoke an application using QTP?

641


What are the two types of repositories available, explain them?

592


In application which areas to be automated and what kind of situation will be take? using QTP? Plz give me the clear answer

1933


What is the difference between keyword view and expert view?

603


What is the difference between run time object and test object in QTP?

564


How many tabs are available in debug viewer pane?

645


How to get Traceability matrix from TD?

668


How to data driven test for Win objects in QTP ?

1468


how to write xml output check point bu useing descriptive programing .means without useing output check point

1652