QTP Realtime Scripts
QTP Realtime Scripts
QTP Realtime Scripts
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.
output
output
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"
Output
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
3.settoproperty and gettoproperty and getroproperty
In this line we have set the "text property" value as 30 using the "Settoproperty"
now the testobject i.e before run time the value for the pincode edit box will be "30"
like this we can set the value for any property of a test object
In this line will also work but we can't see the result.
we can check what value we have set to the pincode edit box by using "GETTOPROPERTY"
OPTION
msgbox a
msgbox b
output
a=30
b=empty
There is no setroproperty. Test object contains only settoproperty and gettoproperty. Runtime object
contains only getro property.
1.properties,2.run,3.resourses,4.parameters,5.environment,6.web,7.recovery
First login naukri account and go to work authorization property and add objects the type the script
browser("Naukri.com - Search
Jobs").page("Mynaukri").WebList("workAuthOtherCountries[]").Select"#1"
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
browser("Naukri.com - Search
Jobs").page("Mynaukri").WebList("workAuthOtherCountries[]").extendSelect"#3"
browser("Naukri.com - Search
Jobs").page("Mynaukri").WebList("workAuthOtherCountries[]").extendSelect"#5"
output
6. how to get all the link count or weblist count or web element count in the naukri home page
descobj("micclass").value= "WebList"
totweblist = weblists.count
print totweblist
For i = 0 to totweblist-1
print weblists(i).getroproperty("Name")
Next
Output
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
descobj("micclass").value= "Link"
totlink = links.count
print totlink
For i = 0 to totlink-1
print links(i).getroproperty("Name")
Next
Output
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
7.
x=day(date)
y=month(date)
z=year(date)
If x<10 Then
x1="0"&x
else
x1=x
End If
If y<10 Then
y1="0"&y
else
y1=y
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
End If
msgbox x1&"/"& y1 &"/"&z
8.how to select particular property from weblist and how to set value in webedit ?
1. Vartype
2. Typename
The below table contains return values that indicate respective subtypes.
Sub
Return Value Description
Datatype
0 vbEmpty Empty (uninitialized)
1 vbNull Null (no valid data)
2 vbInteger Integer
3 vbLong Long integer
Single-precision floating-point
4 vbSingle
number
5 vbDouble Double-precision floating-
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
point number
6 vbCurrency Currency
7 vbDate Date
8 vbString String
9 vbObject Automation object
10 vbError Error
11 vbBoolean Boolean
Variant (used only with arrays
12 vbVariant
of Variants)
13 vbDataObjectA data-access object
17 vbByte Byte
8192 vbArray Array
Dim x
x=10.2
msgbox vartype(x)
output
Sub
Description
Datatype
Byte Byte value
Integer Integer value
Long Long integer value
Single Single-precision floating-point value
Double Double-precision floating-point value
Currency Currency value
Decimal Decimal value
Date Date or time value
String Character string value
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
Boolean Boolean value; True or False
Empty Unitialized
Null No valid data
<object type> Actual type name of an object
Object Generic object
Unknown Unknown object type
Object variable that doesn't yet refer to an
Nothing
object instance
Error Error
dim x
x=10.6
msgbox typename(x)
output
double
Set child_obj=Dialog("text:=Login").ChildObjects
print child_obj.count
child_obj("micclass").value= "WebEdit"
set x = browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(child_obj)
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
totwebedit = x.count
print totwebedit
For i = 0 to totwebedit-1
print x(i).getroproperty("Name")
Next
Set x=createobject("Scripting.FileSystemObject")
a=y.readline()
print a
Wend
Set x=createobject("Scripting.FileSystemObject")
z.writeline("One")
z.writeline("two")
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
z.writeline("three")
z.writeline("four")
z.writeline("five")
14. how to read data from one notepad to wrte another notepad file
Set x=createobject("Scripting.FileSystemObject")
a=y.readline()
z.writeline(a)
print a
Wend
Set x=createobject("Scripting.FileSystemObject")
a=y.readline()
If instr(1,a,"99402") Then
a=replace(a,99,88)
end if
z.writeline(a)
www.ramupalanki.com
For more QTP Scripts, www.ramupalanki.com
print a
Wend
systemutil.Run "iexplore.exe","http://google.com"
Set x=description.Create
x("micclass").value="webedit"
browser("micclass:=browser").page("micclass:=page").webedit("index:=1").set"os
howorld"
browser("micclass:=browser").page("micclass:=page").webbutton("index:=1").Cli
ck
www.ramupalanki.com