Micro Focus QTP (UFT) Forums
Checking that a field cannot go above a certain number of characters - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Checking that a field cannot go above a certain number of characters (/Thread-Checking-that-a-field-cannot-go-above-a-certain-number-of-characters)



Checking that a field cannot go above a certain number of characters - Alx - 06-05-2009

Hi All,

I am testing a web page which has fields on it that have restricted character lengths that are set by javascript.

For example, if a user tries to type more than 10 characters in a field once they get to character 10 they will not be able to type any more characters - no error message appears.

I am stuck on how I would test this using QTP. I need to ensure that it is not possible to type more than 11 characters, how would I go about this?

The code I have written so far is as follows:

Code:
For i = 9 to 10
Browser("Reg").Page("Reg").WebEdit("in_post").Set "XXXX XXXX"&i
sPost(i) = Browser("Reg").Page("Reg").WebEdit("in_post").GetROProperty("value")

msgbox("Post is now "&sPost(i))

Next

If sPost(10) = "XXXX XXXX10" Then
    Reporter.ReportEvent micFail
    Else
        Reporter.ReportEvent micPass
End If

The problem I have with this code is that for the 2nd iteration QTP reports the error 'The parameter is incorrect. Line(82): "Browser("Reg").Page("Reg").WebEdit("in_post").Set "XXXX XXXX"&i"

if anyone can help and suggest some other code that would work then i would be very grateful. Thanks.
for some reason I can't edit my post above??

I want to change one line to say:
'I am stuck on how I would test this using QTP. I need to ensure that it is not possible to type more than 10 characters, how would I go about this?'


RE: Checking that a field cannot go above a certain number of characters - anemuday - 06-05-2009

try getROProperty("max length")

ex:
Code:
retLen=browser("xx").page("xx").webedit("xx").getROProperty("max length")



RE: Checking that a field cannot go above a certain number of characters - Alx - 06-08-2009

I didn't think of that, thanks for your help.