How to Setting Max value?

Submitted by: Administrator
Here's the function you need to verify that an object (TextField) accepts a max char limit.
[code]
[+] boolean VerifyMaxChars (window wTarget, integer iMax, string sChar optional)
[ ]
[ ] string sText = ""
[ ] string sComp
[ ]
[+] if sChar == null
[ ]
[ ] sChar = "A"
[ ]
[ ]
[ ] sText = Replicate (sChar, iMax)
[ ]
[ ] wTarget.TypeKeys (sText)
[ ]
[ ] sComp = wTarget.GetText ()
[ ]
[+] if sText != sComp
[ ]
[ ] Verbose ("Verify Max Chars failed, expected number {iMax}, actual {Len (sComp)}")
[ ]
[ ] return false
[ ]
[ ]
[ ] sText = Replicate (sChar, iMax + 1)
[ ]
[ ] wTarget.SetText (sText)
[ ]
[ ] sComp = wTarget.GetText ()
[ ]
[+] if sText == sComp
[ ]
[ ] Verbose ("Verify Max Chars failed, expected number {iMax}, actual {iMax + 1}")
[ ]
[ ] return false
[ ]
[ ]
[ ] return true
[ ]
[/code]
Submitted by: Administrator

Read Online SilkTest Job Interview Questions And Answers