Forum Discussion

Udayreddy_90's avatar
Udayreddy_90
Contributor
12 years ago

About text box testing

1. How to test Max length of the text box ( Using VBScript)

2. How to test, is the text box accepting numbers values or not ?

3. How to test, is the text box not accepting other then numbers ?

1 Reply

  • Hello Uday,

    I'd use the ObjectSpy to find out what the set limit is for the textbox.

    http://support.smartbear.com/viewarticle/11926/


    Otherwise you could write a loop function to keep appending a single character to the textbox, read the data from the textbox and check the length. Once it's hit the limit the length would remain the same.

    For questions 2 and 3, I assume if you enter in invalid characters, these will be ignored by the textbox. If that's the case, record yourself entering data, then read the textbox and compare with the expected results.


    eg. I've used a Windows 7 machine with the Notepad Save As dialog box open for this example. This textbox is alphanumeric but it's just to show you what I expect if this was a numeric only textbox.

    Sub ForumTextBox()

      'Win 7 Notepad Save As dialog box -> file name textbox

      Set NotepadTextBox = Aliases.NOTEPAD.Window("#32770", "Save As", 1).Window("DUIViewWndClassName", "", 1).Window("DirectUIHWND", "", 1).Window("FloatNotifySink", "", 1).Window("ComboBox", "", 1).Window("Edit", "", 1)

     

      'Textbox limit

      Log.Message("Textbox limit: " & NotepadTextBox.wLimit)

     

      'Set text as whatever

      Call NotepadTextBox.keys("123abc4")

     

      'Read the textbox.

      strText = NotepadTextBox.wText

     

      'Check the content - On a numeric only textbox, the letters would be ignored.

      If (strText = "1234") Then

        Log.Message("Passed")

      Else

        Log.Error("Failed")

      End If

    End Sub


    Cheers,

    Jackson