Dim nChar,s
s=inputbox("input name")
nChar = Asc(s)
If nChar >= 65 And nChar <= 90 Then
msgbox "The first character is UPPERCASE"
ElseIf nChar >= 97 And nChar <= 122 Then
msgbox "The first character is lowercase"
Else
msgbox "The first character isn't alphabetical"
End If
OUTPUT:-
Wednesday, 20 July 2011
The following example uses the InputBox function to display an input box and
Option Explicit
Dim
sPrompt, sTitle, sHelpFile, sResDim
vDefDim
sPrompt =
vDef = "
nXPos =
nYPos, nXPos, nContext"Where do you live?" : sTitle = "Personal Data"Israel"100 : nYPos = 100 : nContext = 1001sHelpFile = "
sRes = C:\WINDOWS\system32\winhelp.hlp"InputBox(sPrompt, sTitle, vDef, nXPos, nYPos, sHelpFile, nContext)
Sunday, 17 July 2011
How to change character's into ASCII number's
sChars = inputbox("Character") 'enter character
MsgBox Asc(sChars) 'converstion into no.
MsgBox Asc(sChars) 'converstion into no.
Validation Script on characte
=========================================================
Dim sChars
Dim nCharCode
sChars = "QuickTest Professional"
If Len(sChars) > 0 Then
nCharCode = Asc(sChars)
If nCharCode >= 97 And nCharCode <= 122 Then
MsgBox "The first character must be uppercase"
Else
MsgBox nCharCode
End If
End If
===================================================================
Dim sChars
Dim nCharCode
sChars = "QuickTest Professional"
If Len(sChars) > 0 Then
nCharCode = Asc(sChars)
If nCharCode >= 97 And nCharCode <= 122 Then
MsgBox "The first character must be uppercase"
Else
MsgBox nCharCode
End If
End If
===================================================================
Tuesday, 12 July 2011
Simlple Validation on Flight Reservation system.
http://www.nitesh10.blogspot.com
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").Type micTab
Dialog("Login").WinButton("OK").Click
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4ab7a2d45ab7f90a0279430e6836a126be044819"
Dialog("Login").WinButton("OK").Click
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
'Enters valid Username
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Dialog("Login").WinEdit("Agent Name:").Set "xyz"
'Again enters invalid Password and then Valid password
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Dialog("Login").WinEdit("Password:").SetSecure "4ab7a30e3dbc0045618cadbeddd91a436bba513d3632"
Dialog("Login").WinButton("OK").Click
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinEdit("Password:").SetSecure "4ab7a3162eda9514506206d258cec02e4e57fb1f"
Dialog("Login").WinButton("OK").Click
http://www.nitesh10.blogspot.com
'Leave Username and password field blanck
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").Type micTab
Dialog("Login").WinButton("OK").Click
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
'Again leaves Username field blank
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4ab7a2d45ab7f90a0279430e6836a126be044819"
Dialog("Login").WinButton("OK").Click
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
'Enters valid Username
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Dialog("Login").WinEdit("Agent Name:").Set "xyz"
'Again enters invalid Password and then Valid password
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Dialog("Login").WinEdit("Password:").SetSecure "4ab7a30e3dbc0045618cadbeddd91a436bba513d3632"
Dialog("Login").WinButton("OK").Click
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinEdit("Password:").SetSecure "4ab7a3162eda9514506206d258cec02e4e57fb1f"
Dialog("Login").WinButton("OK").Click
http://www.nitesh10.blogspot.com
Tuesday, 5 July 2011
static script for flight reservation system
systemutil.Run "iexplore.exe","www.gmail.com"
browser("name:=Gmail: Email from Google").page("title:= Gmail: Email from Google").webedit("name:=email").Set "abcdefgh"
browser("name:=Gmail: Email from Google").page("title:= Gmail: Email from Google").webedit("name:=Passwd").Setsecure "dsdo947u5juo4u85i459859jkuoit9rr5465ret3s"
browser("name:=Gmail: Email from Google").page("title:= Gmail: Email from Google").webbutton("name:=Sign in").click
browser("name:=Gmail - Inbox").page("title:=Gmail - Inbox").link("name:=Compose Mail").click
browser("name:=Gmail - Compose Mail").page("title:=Gmail - Compose Mail").webedit("name:=to").set "xyz@gmail.com"
browser("name:=Gmail - Compose Mail").page("title:=Gmail - Compose Mail").webedit("name:=bcc").set "abc@gmail.com"
browser("name:=Gmail - Compose Mail").page("title:=Gmail - Compose Mail").webedit("name:=subject").set "gmail assignment...,"
browser("name:=Gmail - Compose Mail").page("title:=Gmail - Compose Mail").webedit("name:=body").set "good morning sir..."
browser("name:=Gmail - Compose Mail").page("title:=Gmail - Compose Mail").webbutton("abs_x:=139","abs_y:=251").Click
'browser("name:=Gmail - Compose Mail").page("title:=Gmail - Compose Mail").webbutton("name:=Save Draft","index:=0").Click
'browser("name:=Gmail - Compose Mail").page("title:=Gmail - Compose Mail").webbutton("name:=Save Draft","index:=0").Click
browser("name:=Gmail - Inbox").page("title:=Gmail - Inbox").link("text:=Sign out").click
Monday, 4 July 2011
Script for validation on flight reservation system
invokeapplication"C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe" 'path of the the application flight Reservation
Dim ag_enb
ag_enb = Dialog("text:=Login").WinEdit("attached text:= Agent Name:").CheckProperty("enabled",1) 'for checking the state of the agent name edit box
If ag_enb=true Then
Dim agname,agval
agname=inputbox("Enter the Agent Name:")
agval =aagvalid(agname)
If agval =1 Then
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set agname
else
msgbox "invalid"
End If
Dialog("text:=Login").WinEdit("attached text:=Password:").Set "mercury"
Dialog("text:=Login").WinButton("text:=OK").Click
else
msgbox " Not Enabled"
End If
Dim res_date,dvalid
res_date =inputbox("Please Enter the date in mm/dd/yy Fromat")
dvalid = datevalid(res_date)
If dvalid =1 Then
Window("text:=Flight Reservation").ActiveX("acx_name:=MaskEdBox").Type res_date
else
msgbox "invalid"
End if
Call locvalid()
Window("text:=Flight Reservation").WinButton("text:= FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select 0
Window("text:=Flight Reservation").Dialog("text:=Flights Table").WinButton("text:=OK").Click
msgbox "You have to enter name before pressing the Insert Order button. "
Dim cusname,cusval
cusname=inputbox("Please Enter the Customer name")
cusval =cusvalid(cusname)
Call enab
If i= Window("Flight Reservation").WinRadioButton("Economy").Set Then
msgbox ("The Economy class Price is:-"& window("Flight Reservation").winedit("Price:").GetVisibleText())
End If
If i= Window("Flight Reservation").WinRadioButton("Business").Set Then
msgbox ("The Business class Price is:-"& window("Flight Reservation").winedit("Price:").GetVisibleText())
End If
If i= Window("Flight Reservation").WinRadioButton("First").Set Then
msgbox ("The First class Price is:-"& window("Flight Reservation").winedit("Price:").GetVisibleText())
End If
Call prcomp
Dim tickno,tickval
tickno=inputbox("Please Enter the Ticket number:")
tickval = tickvalid(tickno)
Window("Flight Reservation").WinRadioButton("Economy").Set
Window("Flight Reservation").WinButton("Insert Order").Click
wait 5
Call update
wait 8
Dim inorder
Window("text:=Flight Reservation").WinMenu("menuobjtype:=2").Select "File;Open Order..."
Window("text:=Flight Reservation").Dialog("text:=Open Order").WinCheckBox("text:=&Order No.").Set "ON"
inordr = inputbox("Please Enter the order number:")
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit_2").set inordr
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
'Call delorder
'========================function==============================================
'===================validation function for agent name=========================
Function aagvalid(agname)
Dim aglen
aglen = len(agname)
If aglen>=4 and aglen<=10 Then
aagvalid =1
else
aagvalid=0
End If
End Function
'=========validation function for Flight reservation date=================
Function datevalid(res_date)
Dim date1,mydate,lastdate
date1 =Cdate(res_date)
mydate = Date
lastdate = Dateadd("yyyy",28,date)
If date1>=mydate and date1<=lastdate Then
datevalid =1
else
datevalid =0
End If
End Function
'=========validation function for the location=================
Function locvalid()
Dim loc,loc1,loc2
loc1=inputbox("Please Enter the Fly From Location from-0-Denver,1-Frankfurt,2-London,3-Los Angeles,4-Paris,5-Portland,6-San Francisco,7-Seattle,8-Sydney,9-Zurich")
For loc1= 0 to loc1-1
Window("text:=Flight Reservation").WinComboBox("attached text:=Fly From:").Getitem(loc1)
Next
loc2=inputbox("Please Enter the Fly From Location from-0-Denver,1-Frankfurt,2-London,3-Los Angeles,4-Paris,5-Portland,6-San Francisco,7-Seattle,8-Sydney,9-Zurich")
For loc2=0 to loc2-1
Window("text:=Flight Reservation").WinComboBox("attached text:=Fly From:").Getitem(loc2)
Next
loc = strcomp (loc1,loc2)
If loc=0 Then
msgbox "You have enter the same location"
else
Window("text:=Flight Reservation").WinComboBox("attached text:= Fly From:").Select loc1
Window("text:=Flight Reservation").WinComboBox("attached text:= Fly To:").Select loc2
End If
End Function
'=========function for enabling the insert order button=================
Function enab()
Dim i
i = Window("text:=Flight Reservation").WinEdit("attached text:=Name:").CheckProperty("enabled",1)
If i=true Then
msgbox "Not Enabled"
else
msgbox "Now you can enter in Insert Order button because you have entered the name"
End If
End Function
'=========validation function for customer name==============================
Function cusvalid(cusname)
Dim cuslen,j,k
cuslen = len(cusname)
If cuslen<=20 Then
window("Flight Reservation").winedit("Name:").Set cusname
else
Do While cuslen>20
msgbox "Sorry you can't enter more then 20 character in customer name."
j=inputbox ("Please Enter the customer name below or equal to 20 characters:")
k=len(j)
If k<=20 Then window("Flight Reservation").winedit("Name:").Set j
Exit do
loop
End If
End Function
'=========function for price calculation of Tickets=================
Function prcal(tickno)
Dim tkprc,tkprc1,total1
tkprc=window("Flight Reservation").winedit("Price:").GetVisibleText()
msgbox (" The Ticket Price:-" & tkprc)
msgbox (" The number of Tickets:-" & tickno)
tkprc1=mid (tkprc , 2)
total1=tkprc1* tickno
msgbox (" The total price of Tickets:-$" & total1)
End Function
'=========validation function for Ticket numbers=================
Function tickvalid(tickno)
Dim i
If tickno<=10 Then
window("Flight Reservation").WinEdit("Tickets:").Set tickno
call prcal(tickno)
Else
Do While tickno>10
msgbox "You have enter more then 10 tickets"
i=inputbox ("Please Enter the ticket below or equal to 10:")
If i<=10 Then
window("Flight Reservation").WinEdit("Tickets:").Set i
call prcal(i)
end if
Exit do
loop
End If
End Function
'=========validation function for price comparision of ticket price=================
Function prcomp()
i=Window("Flight Reservation").WinRadioButton("Economy").set
j=Window("Flight Reservation").WinRadioButton("Economy").set
k=Window("Flight Reservation").WinRadioButton("Economy").set
if k=3 * i and j = 2 * i then
msgbox ("First class is 3 time expensive and business class is 2 time expensive then economy class")
else
msgbox("The price of classes are not right")
end if
End Function
'=========function for updation the order=================
Function update()
msgbox ("Now you can update the information in your application")
Window("Flight Reservation").WinButton("Update Order").Click
End Function
'=========function for deletion the order=================
Function delorder()
msgbox("Do You want to delete the order from application")
Window("Flight Reservation").WinButton("Delete Order").Click
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("Yes").Click
End Function
www.nitesh10.blogspot.com
Subscribe to:
Posts (Atom)