QTP supports JAVA script also.....
It suports both VB n JAVA script.
Even in the help u can find both the java n VB script. We
can execute both to get the output.
Just like how we check the VB add-in checkbox in the add-in
Manager screen during the start-up, if java add-in is
enabled we can script using Java script instead of VB.
U can try out.
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.
k.Thanks.
Can u give QTP Frameworks which one uses in real time?
i mean in QTP We have the frameworks are
keyword driven and function library framework and
action,datadriven,hybrid frame works.we can use these
frameworks w.r.to complexsity of application
i want keyword,function library frame work script on Flight
Reservation application.pls prepare that script.
urgently..........pls......
Thanks@Regards
************
Please leave your mail id here. I'll surely drop a Zip file
to you which contains small demo Frame work on Flight
Reservation Application.
Anyhow some part of the demo I am keeping here, Please have
a look at below
QTP Framework Demo VIII
Changes for VIII
All the objects except for the Browser and Page are handled
by Descriptive Programming.
Files:
QTP Script BookFlightDemo.
This script will now only run in QTP 9.1 or later versrions
of QTP like 9.2,9.5 or 10.0 you should be able to backward
engineer the script. You need to convert it to full DP
objects and create a new script in your version QTP and
include all the files below.
Excel.vbs (Data Reading Functions)
GlobalVars.vbs (Holds Global values)
DP_Objects.vbs (Basic Descriptive Programming subs)
Navigation.vbs (Common Navigation subs)
Flights_Demo.xls (Data file (Datatable
replacement))
Instructions
Copy the folder Data to the root directory of you C drive.
Start QTP and open the script BookFlightDemoII.
There will be one Keyword in the QTP script “BookFlights”
This demo uses the Mercury Tours web site which you should
have a link to in your sample applications.
http://newtours.mercury.com/
The start condition is at the login screen.
Make sure all the vbs files are referenced in the resource
panel
QTP > Resources > Associated Function Libraries
When you run the script you will be asked to select a data
file select Flights_Demo.xls.
I have made a few changes from the first version of the
demo. The long lines of code created by QTP when recoding
have been replaced by simple short lines. For example
strBrowser = "Welcome: Mercury Tours"
strPage = "Find a Flight: Mercury"
'Departing From:
Call DPWebList ("fromPort", strFromPort)
The browser and page are set before the fields and are re-
set when required. Descriptive Programming is also used in
this demo now as shown in the example below.
'billAddress1
Call DPWebEdit ("billAddress1", strbillAddress1)
The script will run for 2 iterations it will report 1 pass
and 1 fail.
This is not a full solution for a framework if you want
that give me a job. I have provided examples of putting
common actions into subs that can be called this allows for
easy maintenance of common reusable actions, Again these
may not be ideal candidates for this but its an example of
what you can do.
Govardhan Palla
thnaks.but i did"t get thst examples.i"ll send script to
u.then u"ll check it.
Function Login()
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "radhi"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click
End Function
Function Open_Order()
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu
("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open
Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit
("Edit").Set "3"
Window("Flight Reservation").Dialog("Open Order").WinButton
("OK").Click
End Function
all these are copy and go to File-new-functionlibrary.in
these function library paste that files extension as .qfl.
later for we have to add it references(resources)go to
resources menu-objectrepository-file-export local
objects.in this save functions resources with .tsr.up to
here functions creations over.later if we want to call that
fun.go to resources-associative repository. in that add
that functions.
but am phasing error while calling the functions.
is it right?pls send script like this way and i real time
how to add functions?
Thanks&Regards
**************
Framework which we are going to use in our project is
Hybrid Driven Framework and the application is in Oracle
Apps HRMS technology. But here you should have to know that
the framework which we are going to use is depends on our
Project. Some projects are we suite for Keyword driven
framework and some of the projects are for Hybrid Driven
Framework (some times we can call it as Function Library
Framework). Keyword Driven is Very easy to use and
implement, but when our test script is under more
maintenance mode then the Keyword Driven FW is more
difficult for Automation Developer, since we don't have
full control on the test script, if more than one
Automation Developers are means we will get conficts like
which part of the script is going to modify. Hence to
reduce the complexicity and to get Test script fully under
our control we can use Hybrid Driven Framework but it is
very complex to understand and develop.
In your case what type of error you are getting while
executing your test?
1.first make sure that your test script is going to
identifing the objects (in the application). If it is not,
add repository and Script accordingly.
2.Store the Object rep. in your local Drive with shared
mode (if you are using QTP 9.0 or later version it will
automatically in shared mode)
3.take the script scrap and devide logical functions
according to your wish and store them in .vbs file (here
you can devide all functions in individual .vbs files or
you can combine all together in one .vbs file)
4. Prepare Test Data in internal or external files.
5.Create Driver Script according to your requirement in
mine Test.
5. Add above created functions with the help of File-
>Settings->Resources->add library file
and add the same functions in Add Function Library list
6.Associate Object Rep. to your test. or you can create
some functions like Add Object Rep.dynamically and Add
Excel sheets Dynamically to your Test
Like above you can prepare test environment.
Please get back to me if you've any doubts on the same.
Cheers,
Govardhan
Thanks. r u real time?i dont know so much about qtp.but i
want to learn qtp real time script wat are use in comp.
Is it my process is right r wrong in creating functios.
can we use .qfl insted of .vbs?
i added all objects in objectrepository.i created functions
same as above manner.but getting mistake while calling that
functions. like that mistake as "type mismatch login".
we use only keyword driven fun. and hybrid fun?
hybrid and function driven framework both r same in all
situation? or different?
Thanks
******
Yes I am. And working in Pune based MNC.
Well Radhika, if you compare the functionality of the
file .vbs and .qfl file functions or more or less same.
.vbs function files are not under control our QTP Tool
environment and .qfl functions are typically under control
in QTP Tool environment, you can predict the mean by seeing
the file extension name itself.
Vbs files generic funtions we can use in any environment
until Object Rep is not helpful for that file. For that
file.
And .qfl files are specific to our QTP environment
functions.
For clear idea create one .vbs file with msgbox “testing
the vbs file” on your desktop
and create the .qfl file with same content
and run the both files with out using QTP Tool (that is you
need to double click on the file).
I think now you got the Idea....
For in your error message case..
how you are going to call the function. I mean are you
using any driver script or any scripting to call the
function. First make sure that both names are one and same.
HI,
I crested files using only V.B.Script only(using add
objects in object repository.).
i created files in 2 ways
1)
1st i created functions.(same my functions are like above
on F.R.S).
Then save that files and from there copy and paste in
function library with .qfl
Later i added it resources in objectrepository-export
localobjects with .tsr
Up to here functions created over.
Now i called that functions(i gave name as Login() and Order
() these r 2 functions i created using v.b script)
Then i have given
call Login()
call Order()
i saved it and later while calling that functions added i
created fun. in associativerepository)
Then i got thst type of mistake.
2nd way
Same created fun. copy and save its in notepad(.txt).
Later add save for references in exportlocalobjects
with .tsr
While calling that fun.getting same mistake.
and another ine
do u know about AD-HOC testing?these r 5 types right
monkey,buddytesting,exploratory(artisting),pair testing,Be-
bugging testing.
Due to lack of documents and due to lack of time and lack
of skills we conduct this testing. just i know it.have we
prepare seperate testcases for ad-hoc testing?
but how to conduct that testing?
ex:in 1 comp available ad-hoc testing only.that means?if it
has projects are rare or comp timing are strict?wat it
means?
pls gve reply urgently with details
(ur giving urgent reply with good information)
Thanks for ur patiency and thanks to u also
******
radhika
First leave the terms which u have learned in the
institute, everyone knows abt the definitions of that
institute (HYD). at basic level it is fine. try to ref
some standard books.
can u explain how to conduct AD-HOC TESTING?
For it, have we seperate test cases for ad-hoc testing.i
want to leave institue(hyd) terms.so that purpose am asking
about real time process.
Pls explain about AD-HOC testing....
Hi,
i am mallishwari,
i am veryn ew to testing but i have very much interest in
testing.
plse give me some guidence to get the job in testing.
send me required documents and faqs to
my personal id:
mallishwari_urs@yahoo.co.in
thans for advance.
How do you find out whether the string is Numeric or Alpha
numenric.Suppose..'QTP is an automation testing tool 12345'
How should I know it is alphanumeric.Can any one please
write the code for this
If there r 1000 test scripts that were written. If a change
to any functionality is to be made then how can we know in
which script is this functionality existing.
Hi,iam new to automation and i have 1 year experience in
manual testing.I have a little bit idea about QTP9.0 .But i
have no idea about script writing using VB.Please help to
learn script writing.