Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Page Validation for Web Application
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi All,

Please show sample scripts for validating mandatory fields of a web page. I want to check if user tries to save form data without entering data for mandatory field, if the developers has called the required function or not.


Thanks
Swati
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
I am assuming the scenario as: There is a webpage with fields User Name, Place and DOB. User Name is required field and other 2 are optional. Here when user selects Save button without entering data for Usert ID, system should display error as "Please enter User Name" (Developer calls error function/script at this point).
1. Check the data in that field is empty
Code:
Data1=Browser("").Page("").WEbEdit("name:=Usert ID").GetROProperty("value")
2. Fetch the Error message if displayed on the WebPage. (User descriptive programming here)
By using 1 and 2 we can validate the scenario.
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago Wink 
Hi,

You may take the basic idea from the below code.

The logic is simple submit the form with blank mandatory field & validate the text of popup message.


Code:
'/ *    used of child object to to find out simlar objects(includes mandatory object too)
                                     Set objDef = Description.Create
                                     objDef("micclass").value="WebElement"  ' specific to app
                                     objDef("html tag").value="DIV"     ' specific to app
                                     objDef("class").value="req"        ' specific to app
                                     Set arrObj= Browser("Browser Name").Window("Window Name").Page("Page Name").Frame("Frame Name").ChildObjects(objDef)
                            
'/ *    Getting the child object count.
                                      n= arrObj.count
                            
'/ *    The loop basically used to find out all the mandatory fields visible on the chart window.
                                     For iCnt =1to n-1

'/ *    getting the "html id" value of the current child object .
                                           strReq = arrObj(iCnt).GetROProperty("html id")   ' specific to app
                                           If len(strReq)>3 Then   ' specific to app

'/ *    Using the select case to compare the "html id" to  find out the required filed.        
                                             Select Case strReq
                  
                                                      Case "FNAME_REQ"   ' specific to app
                                                        Browser("Browser Name").Window("Window Name").Page("Patient Chart Page").WebButton("Apply").Click
'/ *        Wait for popup box
                                                        Browser("Browser Name").Window("Window Name").Dialog("Windows Internet Explorer").WinButton("OK").WaitProperty "enabled","True",4000
'/ *         Checkpoint for verifying the popup box property like text.
                                                        Browser("Browser Name").Window("Window Name").Dialog("Windows Internet Explorer").Static("FieldMessage").Check CheckPoint("First Name")
                                                        Browser("Browser Name").Window("Window Name").Dialog("Windows Internet Explorer").WinButton("OK").Click
'/ *       Enter the 'First Name'  in the Frame.        
                                                    Browser("Browser Name").Window("Window Name").Page("Page Name").Frame("Frame Name").WebEdit("First Name").Set "Ankur"
                                            
                                                        Case "DOB_REQ"  ' specific to app
                                                         Browser("Browser Name").Window("Window Name").Page("Patient Chart Page").WebButton("Apply").Click
'/ *        Wait for popup box  
                                                         Browser("Browser Name").Window("Window Name").Dialog("Windows Internet Explorer").WinButton("OK").WaitProperty "enabled","True",4000
'/ *         Checkpoint for verifying the popup box property like text.
                                                         Browser("Browser Name").Window("Window Name").Dialog("Windows Internet Explorer").Static("FieldMessage").Check CheckPoint("Birth Date")
                                                         Browser("Browser Name").Window("Window Name").Dialog("Windows Internet Explorer").WinButton("OK").Click
'/ *        Enter the 'Birth Day' in the Frame.  
                                                        Browser("Browser Name").Window("Window Name").Page("Page Name").Frame("Frame Name").WebEdit("Month").Set "01"
                                                        Browser("Browser Name").Window("Window Name").Page("Page Name").Frame("Frame Name").WebEdit("Day").Set "10"
                                                        Browser("Browser Name").Window("Window Name").Page("Page Name").Frame("Frame Name").WebEdit("Year").Set "1995"
                                                               End Select
                                            End If
                                        Next

I hope this will help you....

Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can QTP handle slick grid table in a web page qtplearner88 2 4,491 10-01-2019, 10:44 AM
Last Post: shilpi952
  DP Web Browser/Page issues rstimers 1 2,435 08-14-2015, 12:37 PM
Last Post: venkatesh9032
  webfile web object not identified at runtime in a java application saila123 1 2,808 02-11-2015, 08:23 PM
Last Post: Kirill
Smile find out of spelling error in Web application deveshbhatt29 1 2,206 01-10-2014, 05:10 PM
Last Post: Maheep_bhambri
Question Capture Entire Web page through QTP learnQtptips 2 11,917 07-25-2013, 05:24 PM
Last Post: vinod123

Forum Jump:


Users browsing this thread: 1 Guest(s)