Micro Focus QTP (UFT) Forums
Direct function or method - 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: Direct function or method (/Thread-Direct-function-or-method)



Direct function or method - raaj123 - 05-26-2013

hi all,

a string in edit box how to conform whether the string is alphabets or numeric or special characters..

regards,
raaj.


RE: Direct function or method - venugqtp - 05-27-2013

you can try with IsNumeric to check numbers, If you want to check some combination of 'string, numbers and special chars' go for Regular Expression.


RE: Direct function or method - raaj123 - 05-27-2013

hi,

thank you
can u pls give me the detailed script for all possible combinations.

regards,
raaj.


RE: Direct function or method - venugqtp - 05-28-2013

Code:
'vStr = "test"
'vStr = "@#$"
vStr = "12345"
Set oReg = New RegExp
oReg.Pattern = ".*\W.*"
Set Matches = oReg.Execute(vStr)

If Matches.count > 0 Then
    print "Input has Special character"
Else
    print "Input has no Special character"
End If

If IsNumeric(vstr) Then
    print "Input has Numeric character"
Else
    print "Input has no Numeric character"
End If

Please refer QTP Help file for Regular Expression Patterns


RE: Direct function or method - idtestingking - 09-03-2013

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"



RE: Direct function or method - jacosta - 09-07-2013

Hi,
I use Array.

Code:
MyArray(2)
MyArray(0)="lkjdñlaskdjas"
MyArray(1)="123456"
MyArray(2)="$%&$"

for i=0 to ubound(MyArray)
  
Windows("some").Dialog("some").WinEdit("some").Type MyArray(i)
  'valid message o invalid message
  reporter.reportevent micPass .... or reporter.reportevent micFail...
next

You need know the valid value for the object control.

Regards.