a).Check whether the button exists or
not. If exists,check whether it is enabled or not.If enabled,click on that
button.
Install
actiTIME1.5 into ur system.
Add
Login now button to the Object Repository.Then write the code in qtp
Set
mybutton=browser(“actiTIME – Login”).Page(“actiTIME – Login”).WebButton(“Login
now”)
buttonclick
mybutton ‘ function call
Function
buttonclick(mybutton)
sstepname=”Button
click”
sobjtype=mybutton.ToString ‘
returns name and type of the object
msgbox
sobjtype
bexists=mybutton.Exist(2)
‘
check whether the button exists or not
If
bexists Then
smsg=sobjtype&”
is exists”
reporter.ReportEvent
micPass,sstepname,smsg
else
smsg=sobjtype&”does
not exists”
reporter.ReportEvent
micFail,sstepname,smsg
exittest
End
If
bdisabled=mybutton.GetROProperty(“disabled”)
‘Check
whether the button is enabled or not
If
disabled=0 Then
smsg=sobjtype&”
is enabled”
reporter.ReportEvent
micPass,sstepname,smsg
else
smsg=sobjtype&”
is disabled”
reporter.ReportEvent
micFail,sstepname,smsg
exittest
End
If
‘
Click on the button
smsg=”Click
on “& sobjtype
reporter.ReportEvent
micPass,sstepname,smsg
mybutton.Click
End
Function
b).Check whether the edit box exists
or not.If exists check whether it is enabled or not. If enabled ,enter text into it.
In
this example we are passing username,pwd and clicking Login button
Add
username,pwd and login to the Object Repository.And write the code in qtp
Function
login(username,pwd)
Set
editbox=browser(“actiTIME – Login”).Page(“actiTIME –
Login”).WebEdit(“username”)
msg=editbox.ToString
If
editbox.Exist Then
msgbox msg&”
exists”
If editbox.GetROProperty(“disabled”)=0 Then
msgbox
msg&” enabled”
End
If
else
Exittest
End
If
Set
pwdbox=browser(“actiTIME – Login”).Page(“actiTIME – Login”).WebEdit(“pwd”)
Set
button=browser(“actiTIME – Login”).Page(“actiTIME – Login”).WebButton(“Login
now”)
editbox.Set
username
pwdbox.Set
pwd
button.Click
End
Function
Call
login(“admin”,”manager”)
No comments:
Post a Comment