Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
An important update from QtpSudhakar. I stopped giving classroom training in MindQ Systems. I have bigger plans and I want to put an end to regular classroom training because very less people are practicing. From now onwards every session of mine is going to have explanation and practice. Everyone should practice in presence of mine and should go out of classroom with practical knowledge. So I started my own institute AnyTechLabs in Madhapur. Please reach out to +91-8328152362 for course details. Visit AnyTechLabs.com for address details.
Selenium + Cucumber 22nd September 9 AM IST to 2.00 PM IST 4 WeekEnds Theory + Practical AnyTechLabs
Selenium + Cucumber 8th October 7.30 AM IST to 9.00 AM IST 45 Days Theory+Practical AnyTechLabs

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Thursday, May 17, 2012

All about Validation of Editbox – Part-2 - Character Acceptance

This article is the continuation of my previous post All about Validation of Editbox – Part-1. This will discuss about edit box character acceptance.
Usually there are 3 text character types used to enter in edit box. Sometimes it can be a combination from these three types.
  1. Alphabetic
  2. Numeric
  3. Special characters
When you check the character acceptance for an edit box using QTP, the edit box will always accept all the values which are coming from QTP. Even though if that edit box is developed to enter only alphabetic or only numeric or only special characters. But when any user enters the value it accepts only the values for which it is developed. As I said before Automation Testing is Not like Automating the Application Functionalities. Its should Replicate the Exact Manual Actions”. So to replicate exact manual actions we have to use SendKeys method in WSH.
The below function is useful in such conditions

Function ValidateCharacterAcceptance(oEditObject,oTypeofEditBox)
 
'Variable Declaration
Dim wsh
Dim oTypingText
Dim oVisibleText
 
'Assign a text value to the variable which is having all value types
oTypingText="SudhakarKakunuri1234@!#$"
 
'clear the values of edit box and focus on it by clicking
oEditObject.Set ""
oEditObject.Click
'Wait is to clear some disturbance
wait(1)
 
'Create wscript object
set wsh=CreateObject("wscript.shell")
 
'Send text using sendkeys method
wsh.SendKeys oTypingText
 
'Wait is to clear some disturbance
wait(1)
 
'Get the visible text of the edit box
oVisibleText=oEditObject.GetROProperty("value")
 
'User can enter any type of text. But editbox accepts only the text which it is meant for.
'The below condition check the visible text based on the text type. 
'If the type of visible text doesnot match the type of the edit box then the condition fails
 
Select Case lcase(oTypeofEditBox)
 
Case "alphabetic"
 
If oVisibleText="SudhakarKakunuri" then
Reporter.ReportEvent micPass,"Check Alphabetic Character Acceptance", "Typed Text: "& oTypingText &vbnewline& "Visible Text: "& oVisibleText
Else
Reporter.ReportEvent micFail,"Check Alphabetic Character Acceptance", "Typed Text: "& oTypingText &vbnewline& "Visible Text: "& oVisibleText
End If 
 
Case "numeric"
 
If oVisibleText="1234" then
Reporter.ReportEvent micPass,"Check Numeric Character Acceptance", "Typed Text: "& oTypingText &vbnewline& "Visible Text: "& oVisibleText
Else
Reporter.ReportEvent micFail,"Check Numeric Character Acceptance", "Typed Text: "& oTypingText &vbnewline& "Visible Text: "& oVisibleText
End If
Case "alphanumeric"
 
If oVisibleText="SudhakarKakunuri1234" then
Reporter.ReportEvent micPass,"Check AlphaNumeric Character Acceptance", "Typed Text: "& oTypingText &vbnewline& "Visible Text: "& oVisibleText
Else
Reporter.ReportEvent micFail,"Check AlphaNumeric Character Acceptance", "Typed Text: "& oTypingText &vbnewline& "Visible Text: "& oVisibleText
End If 
 
Case "alphanumericspecial"
 
If oVisibleText=oTypingText then
Reporter.ReportEvent micPass,"Check AlphaNumericSpecial Character Acceptance", "Typed Text: "& oTypingText &vbnewline& "Visible Text: "& oVisibleText
Else
Reporter.ReportEvent micFail,"Check AlphaNumericSpecial Character Acceptance", "Typed Text: "& oTypingText &vbnewline& "Visible Text: "& oVisibleText
End If 
End Select
 
Set wsh= nothing
End Function
 
'Calling the Function
Set oEditObject=Browser("").Page("").WebEdit("")
ValidateCharacterAcceptance oEditObject,"alphanumericspecial"

Please send your Suggestions and Doubts to my yahoo group http://in.groups.yahoo.com/group/qtpsudhakar

2 comments :