Basic Editbox Testing Checklist:-
- Maximum Length
- Characters Acceptance
- Alpha Characters Only
- Numeric Characters Only
- Alpha Numeric Characters Only
- Alpha Numeric Custom Characters
- Clipboard Text Acceptance
- Enable / Disable
- Text Encryption
To understand this post the reader should already know about
- String Function in VBScript
- GetROProperty Method in QTP
- SendKeys Method in WSH Scripting
1. Maximum Length Validation
Identifying max length is possible by using a property called “max length”. But its a little tricky if we want to test by entering the maximum number of characters. Suppose a textbox support 7 characters. In this case we have to make a try, to enter 8 characters. If we try to enter using “set” method QTP pops up an error saying “The parameter is incorrect.”. In this case we have to for sendkeys method from wsh scripting. Using this we can replicate manual typing.
Automation Testing is Not like Automating the Application Functionalities. Its should replicate the exact Manual Actions.
__________________________________________________________
'**********************************************************************************
Function ValidateTextboxMaxLength(oEditObject,oMaxLen)
Dim wsh
Dim oMaxStr
Dim iValue
set wsh=CreateObject("wscript.shell")
oMaxStr=string(oMaxLen+1,"s")
oEditObject.Set ""
oEditObject.Click
wait(1)
wsh.SendKeys oMaxStr
iValue=oEditObject.GetROProperty("value")
If len(iValue)=oMaxLen then
Reporter.ReportEvent micPass,"Textbox Max Length Validation","Textbox support a Maximum of "& oMaxLength&" Characters"
else
Reporter.ReportEvent micFail,"Textbox Max Length Validation","Textbox support more than "& oMaxLength&"Characters"
End If
Set wsh= nothing
End Function
'**********************************************************************************
‘Calling the Function
set EditObj=Browser("").Page("").WebEdit("")
ValidateTextboxMaxLength EditObj
'OR
RegisterUserFunc "WebEdit","ValidateTextboxMaxLength”,"ValidateTextboxMaxLength”
Browser("").Page("").WebEdit("").ValidateTextboxMaxLength
UnregisterUserFunc "WebEdit","ValidateTextboxMaxLength"
Part2-- Characters Acceptance Validation__________________________________________________________
Osam logic..Thanks again for sharing knowledge..
ReplyDeleteBut code missing oMaxLen=Editobj.GetroProperty("max length")
One more thing is thr but I think its intentionally..:)
u gotta pass the omaxlength value to the function k jitendra the code is correct
ReplyDeleteExcillent artical.
ReplyDeleteThanks man
Excillent artical.
ReplyDeleteThanks man
Excillent artical
ReplyDeletetoo good man !!!
ReplyDeleteGood Article Sudhakar,
ReplyDeleteThere is a small typo error I guess on the Reporter.Event line.
Reporter.ReportEvent micFail,"Textbox Max Length Validation","Textbox support more than "& *************oMaxLength*************&"Characters"
It should be oMaxLen which is typed as oMaxLength in the above line.
Regards,
Veeranki Naveen.
One more type error is on Line number 31 i.e one of the parameter is missed.
ReplyDeleteValidateTextboxMaxLength EditObj , MaxLen
Regards,
Veeranki