Interview Questions

How to Setting Max value?

SilkTest Questions and Anwsers


(Continued from previous question...)

67. How to Setting Max value?

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]

(Continued on next question...)

Other Interview Questions