09-03-2013, 03:34 PM
Code:
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="tester1234@!#$"
'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="tester" 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="tester1234" 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
SystemUtil.Run "iexplore.exe","http://192.168.1.210:8081"
Browser("name:=FMS - Login").Page("title:=FMS - Login").WebEdit("name:=UserName").Set "admin1"
Browser("name:=FMS - Login").Page("title:=FMS - Login").WebEdit("name:= Password").Set "admin1"
Browser("name:=FMS - Login").Page("title:=FMS - Login").webbutton("class:=loginbtn").Click
Browser("name:=FMS - Home Page").Navigate "http://test.com/Home/Index#url=%2FPerson%2FCreate"
Set oEditObject=Browser("name:=FMS - User Create").Page("title:=FMS - User Create").WebEdit("name:=Person.Phone")
ValidateCharacterAcceptance oEditObject,"alphanumericspecial"