Title: Testing JavaScript alert

Hi,
I have a textarea field that should restrict the input to 40 chars. So I set up the following _javascript_ in my JSP


                function textLimit(field, maxlen) {
                        if (field.value.length > maxlen + 1) {
                                alert('You have reached the maximum number of characters allowed!');
                        }
                        if (field.value.length > maxlen)
                                field.value = field.value.substring(0, maxlen);
                }                  

I call this _javascript_ like this:

      <textarea cols = "25" rows = "2" name = 'userEnteredText' id = 'myfield'
                onkeyup="textLimit(this, 337);" />


In the Java testcase I am writing I am setting the form field to 41 chars and expecting that the above _javascript_ alert will kick in.

It does do so interactively, but in the test case how do I assert that the alert must pop up or the testcase has failed.

                setFormElement("userEnteredText", "a more than 40 char long string typed on");

What API do I use to assert this alert popup.

Thanks

Vijay Kumar

Reply via email to