Form Field Validation
Question ID: 105630
2
0

We have a web page that displays a message when a field has invalid data in it, and we need to validate that the correct message is being displayed. Sample HTML code is:

Username:

How do I validate that the proper message is displayed?

Marked as spam
Posted by (Questions: 386, Answers: 64)
Asked on October 23, 2014 6:30 pm
62 views
Answers (2)
2
Private answer

This is an HTML 5 feature and is not natively supported by UFT. You can't do any checkpoints on it because it is not persistent and goes away immediately upon losing focus. However, there is a way around it:

1. Open the object repository and highlight Test Objects in the left pane.
2. Click the Define New Test Object icon.
3. Set the following properties:
Environment: Web
Class: Page
Name: Whatever you want. For this example, we'll call it Validator
4. Click Add.
5. Click the Validator object in the object tree.
6. Change the Ordinal Identifier to Type:Index, Value:0
7. With the Validator page still highlighted, click the Define New Test Object icon again.
8. Set the following properties (Delete any other properties):
Environment: Web
Class: WebElement
Name: Whatever you want. For this example, we'll call it Validation
html tag: DIV
html id: contentContainer
9. Click Add.
10. In your test, do whatever causes the validation message to appear.
11. Use the following code to grab the text of the validation message:

strMessage = Page(''Validator'').WebElement(''Validation'').GetROProperty(''innertext'')

Now you can validate that strMessage contains the text you expect.

Marked as spam
Posted by (Questions: 16, Answers: 807)
Answered on October 23, 2014 6:31 pm
0
That's so awesome!
( at October 23, 2014 6:32 pm)
0
Private answer

You could also use descriptive programming to get the object.


 strMessage = Page(''index:=0'').WebElement(''html tag:=DIV'', ''html id:contentContainer'').GetROProperty(''innertext'')

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on October 23, 2014 6:39 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top