Answers

Question and Answer:

  Home  SilkTest

⟩ 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]

 205 views

More Questions for you: