You are on page 1of 12

For more QTP Scripts,

www.ramupalanki.com
1. How to select particular property in weblist from browser?
First open object repository then click add objects then go to naukri
homepage and click naukri homepage title bar then select weblist or entire
properties then click ok.
Now go to qtp then type script
browser("Naukri.com - Search Jobs").Pae("Naukri.com - Search
Jobs").!eb"ist("#$%&").Select "'("
output
browser("Naukri.com - Search Jobs").Pae("Naukri.com - Search
Jobs").!eb"ist("#$%&").Select "')"
output
2. How to set alues in web edit class?
First login naukri account then go to others then go to personal details then
add pincode property into object repository the go to qtp type the script
In this line we have set the value as 23 to the pincode edit box... this is "SET METHOD"
*rowser("Naukri.com - Search
Jobs").Pae("+,naukri").!eb-.it("pinco.e").Set ")("
/utput
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
*rowser("Naukri.com - Search
Jobs").Pae("+,naukri").!eb-.it("pinco.e").Set "012)1)"
!.settoproperty and gettoproperty and getroproperty
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
In this line we have set the "text propert" value as 3! usin" the "Settopropert"
now the testob#ect i.e be$ore run ti%e the value $or the pincode edit box will be "3!"
li&e this we can set the value $or an propert o$ a test ob#ect
In this line will also wor& but we can't see the result.
browser("Naukri.com - Search
Jobs").Pae("+,naukri").!eb-.it("pinco.e").SetT/Propert, "te3t",(1
we can chec& what value we have set to the pincode edit box b usin" "(ETTO)*O)E*T+"
O)TIO,
a4 browser("Naukri.com - Search
Jobs").Pae("+,naukri").!eb-.it("pinco.e").5etT/Propert, ("te3t")
b4 browser("Naukri.com - Search
Jobs").Pae("+,naukri").!eb-.it("pinco.e").5et6/Propert, ("te3t")
msbo3 a
msbo3 b
output
a4(1
b4empt,
There is no setropropert,. Test ob7ect contains onl, settopropert, an.
ettopropert,. 6untime ob7ect contains onl, etro propert,.
".test settings contains # tabs
8.properties,).run,(.resourses,2.parameters,9.en:ironment,0.web,;.reco:
er,
$. how to multiple select at the same time
First loin naukri account an. o to work authori<ation propert, an. a..
ob7ects the t,pe the script
browser("Naukri.com - Search
Jobs").pae("+,naukri").!eb"ist("work=uth/ther>ountries%&").Select"'8"
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
browser("Naukri.com - Search
Jobs").pae("+,naukri").!eb"ist("work=uth/ther>ountries%&").e3ten.Sele
ct"'("
browser("Naukri.com - Search
Jobs").pae("+,naukri").!eb"ist("work=uth/ther>ountries%&").e3ten.Sele
ct"'9"
output
0. how to et all the link count or weblist count or web element count in
the naukri home pae
Set .escob7 4 .escription.>reate
.escob7("micclass").:alue4 "!eb"ist"
set weblists 4
browser("micclass?4*rowser").Pae("micclass?4Pae").>hil./b7ects(.esco
b7)
totweblist 4 weblists.count
print totweblist
For i 4 1 to totweblist-8
print weblists(i).etropropert,("Name")
Ne3t
/utput
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
Set .escob7 4 .escription.>reate
.escob7("micclass").:alue4 ""ink"
set links 4
browser("micclass?4*rowser").Pae("micclass?4Pae").>hil./b7ects(.esco
b7)
totlink 4 links.count
print totlink
For i 4 1 to totlink-8
print links(i).etropropert,("Name")
Ne3t
/utput
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
#.
%&day'date(
y&month'date(
)&year'date(
*f %+1, -hen
%1&.,./%
else
%1&%
0nd *f
*f y+1, -hen
y1&.,./y
else
y1&y
0nd *f
msgbo% %1/.1./ y1 /.1./)
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
2.how to select particular property from weblist and how to set alue in
webedit ?
browser'.Naukri.com 3 4earch 5obs.(.6age'.Naukri.com 3 4earch
5obs.(.weblist'.qf78.(.4elect.9!.
a&browser'.Naukri.com 3 4earch 5obs.(.6age'.Naukri.com 3 4earch
5obs.(.weblist'.qf78.(.getroproperty'.alue.(
msgbo% a
browser'.Naukri.com 3 4earch
5obs.(.6age'.:ynaukri.(.;eb0dit'.pincode.(.4et.<,"2,2.
a&=rowser'.Naukri.com 3 4earch 5obs.(.6age'.:ynaukri.(.;eb0dit'.pincode.(.
>et?@6roperty'.alue.(
msgbo% a
9. How to find Data Type of a Variable?
The data type of a variable can be indentified in two VBScript built-in
functions.
1. Vartype
2. Typename
Vartype returns a numeric value indicating the sub datatype of a
variable.
The below table contains return values that indicate respective subtypes.
Return Value
Sub
Datatype
Description
0 vbmpty mpty !uninitiali"ed#
1 vb$ull $ull !no valid data#
2 vb%nteger %nteger
& vb'ong 'ong integer
( vbSingle
Single-precision floating-point
number
) vb*ouble *ouble-precision floating-
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
point number
+ vb,urrency ,urrency
- vb*ate *ate
. vbString String
/ vb0b1ect 2utomation ob1ect
10 vbrror rror
11 vbBoolean Boolean
12 vbVariant
Variant !used only with arrays
of Variants#
1& vb*ata0b1ect2 data-access ob1ect
1- vbByte Byte
.1/2 vb2rray 2rray

Aim %
%&1,.2
msgbo% artype'%(
output
$
Typename directly returns the name of the Sub *atatype of a variable.
Sub
Datatype
Description
Byte Byte value
%nteger %nteger value
'ong 'ong integer value
Single Single-precision floating-point value
*ouble *ouble-precision floating-point value
,urrency ,urrency value
*ecimal *ecimal value
*ate *ate or time value
String ,haracter string value
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
Boolean Boolean value3 True or 4alse
mpty 5nitiali"ed
$ull $o valid data
6ob1ect type72ctual type name of an ob1ect
0b1ect 8eneric ob1ect
5n9nown 5n9nown ob1ect type
$othing
0b1ect variable that doesn:t yet refer to an
ob1ect instance
rror rror

dim %
%&1,.<
msgbo% typename'%(
output
double
1,. count the number of child objects of Bight reseration application
inokeapplication.0CD6rogram FilesD:ercury *nteractieDEuick-est
6rofessionalDsamplesDBightDappDBight"a.
4et childFobj&Aialog'.te%tC&Gogin.(.Hhild@bjects
print childFobj.count
11.child objects method'google page(
4et childFobj & description.Hreate
childFobj'.micclass.(.alue& .;eb0dit.
set % &
browser'.micclassC&=rowser.(.6age'.micclassC&6age.(.Hhild@bjects'childFobj(
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
totwebedit & %.count
print totwebedit
For i & , to totwebedit31
print %'i(.getroproperty'.Name.(
Ne%t
12. how to read data from notepad Ile?
JHow to read te%t from notepad using Ilesystemobject
4et %&createobject'.4cripting.File4ystem@bject.(
4et y& %.@pen-e%tFile'.0CDAocuments and
4ettingsD4udhaDAesktopDgod.t%t.K1(
;hile not y.atendofstream
a&y.readline'(
print a
;end
1!. how to write data in the new notepad Ile?
4et %&createobject'.4cripting.File4ystem@bject.(
4et )& %.@pen-e%tFile'.0CDAocuments and
4ettingsD4udhaDAesktopDlord.t%t.K2(
).writeline'.@ne.(
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
).writeline'.two.(
).writeline'.three.(
).writeline'.four.(
).writeline'.Ie.(
1". how to read data from one notepad to wrte another notepad
Ile
4et %&createobject'.4cripting.File4ystem@bject.(
4et y& %.@pen-e%tFile'.0CDAocuments and
4ettingsD4udhaDAesktopDgod.t%t.K1(
4et )& %.@pen-e%tFile'.0CDAocuments and
4ettingsD4udhaDAesktopDlord.t%t.K2(
;hile not y.atendofstream
a&y.readline'(
).writeline'a(
print a
;end
1$.how to replace from one particular notepad to another notepad
4et %&createobject'.4cripting.File4ystem@bject.(
4et y& %.@pen-e%tFile'.0CDAocuments and
4ettingsD4udhaDAesktopDgod.t%t.K1(
4et )& %.@pen-e%tFile'.0CDAocuments and
4ettingsD4udhaDAesktopDlord.t%t.K2(
;hile not y.atendofstream
www.ramupalanki.com
For more QTP Scripts,
www.ramupalanki.com
a&y.readline'(
*f instr'1KaK.LL",2.( -hen
a&replace'aKLLK22(
end if
).writeline'a(
print a
;end
1<. how to set alue in web page using descriptie
systemutil.?un .ie%plore.e%e.K.httpC11google.com.
4et %&description.Hreate
%'.micclass.(.alue&.webedit.
browser'.micclassC&browser.(.page'.micclassC&page.(.webedit'.i
nde%C&1.(.set.oshoworld.
browser'.micclassC&browser.(.page'.micclassC&page.(.webbutton
'.inde%C&1.(.Hlick
www.ramupalanki.com

You might also like