• No results found

VB Script Pocedures

N/A
N/A
Protected

Academic year: 2021

Share "VB Script Pocedures"

Copied!
15
0
0

Loading.... (view fulltext now)

Full text

(1)

---VB Script Procedures/Functions

VB Script Procedures/Functions

---

---Sub Login(Agent, Password) Sub Login(Agent, Password) SystemUtil.Run "C:\Program

SystemUtil.Run "C:\Program Files\HP\QuickTFiles\HP\QuickTestest Professional\samples\f

Professional\samples\flight\app\flight4a.exe","","C:\Progrlight\app\flight4a.exe","","C:\Program am Files\HP\QuickTFiles\HP\QuickTestest Professional\samples\flight\app\","open"

Professional\samples\flight\app\","open" Dialog("Login").Activate

Dialog("Login").Activate

Dialog("Login").WinEdit("Agent Name:").Set Agent Dialog("Login").WinEdit("Agent Name:").Set Agent Dialog("Login").WinEdit("Passw

Dialog("Login").WinEdit("Password:").Set ord:").Set PasswordPassword wait 1

wait 1

Dialog("Login").WinButton("OK").Click Dialog("Login").WinButton("OK").Click

If Window("Flight Reservation").Exist(10) Then If Window("Flight Reservation").Exist(10) Then

Msgbox "Login Operation

Msgbox "Login Operation Sucessful"Sucessful" Else

Else

SystemUtil.CloseDescendentProcesses SystemUtil.CloseDescendentProcesses Msgbox "Login Failed"

Msgbox "Login Failed" End If 

End If  End Sub End Sub Call

Call Login("acd","mercurLogin("acd","mercury")y")

---Function

Function Login(Agent, Login(Agent, Password)Password) SystemUtil.Run "C:\Program

SystemUtil.Run "C:\Program Files\HP\QuickTFiles\HP\QuickTestest Professional\samples\f

Professional\samples\flight\app\flight4a.exe","","C:\Progrlight\app\flight4a.exe","","C:\Program am Files\HP\QuickTFiles\HP\QuickTestest Professional\samples\flight\app\","open"

Professional\samples\flight\app\","open" Dialog("Login").Activate

Dialog("Login").Activate

Dialog("Login").WinEdit("Agent Name:").Set Agent Dialog("Login").WinEdit("Agent Name:").Set Agent Dialog("Login").WinEdit("Passw

Dialog("Login").WinEdit("Password:").Set ord:").Set PasswordPassword wait 1

wait 1

Dialog("Login").WinButton("OK").Click Dialog("Login").WinButton("OK").Click

If Window("Flight Reservation").Exist(10) Then If Window("Flight Reservation").Exist(10) Then

Window("Flight

Window("Flight Reservation").ClosReservation").Closee Login= "Login Operation

Login= "Login Operation Sucessful"Sucessful" Msgbox Login Msgbox Login Else Else SystemUtil.CloseDescendentProcesses SystemUtil.CloseDescendentProcesses Login= "Login Failed"

Login= "Login Failed" Msgbox Login Msgbox Login End If  End If  End Function End Function Call

Call Login("accd","mercLogin("accd","mercury")ury")

---'Write a Function to Count all

'Write a Function to Count all Opened Browsers on desktop and close themOpened Browsers on desktop and close them all

all

Function

Function Close_Browsers(Close_Browsers()) Dim oBrowser, Browsers,

(2)

Set

Set oBrowser=DescoBrowser=Description.Createription.Create

oBrowser("micclass").value="Browser" oBrowser("micclass").value="Browser" Set

Set Browsers=DesktBrowsers=Desktop.ChildObjects(oBrowsop.ChildObjects(oBrowser)er) TotBrowsers=Browsers.count

TotBrowsers=Browsers.count

For i= 0 to

For i= 0 to TotBrowsers-1 Step 1TotBrowsers-1 Step 1 Browsers(i).close Browsers(i).close Next Next End Function End Function Call

Call Close_BrowsersClose_Browsers()()

---'Write a Function to Count Links in

'Write a Function to Count Links in any opened webpageany opened webpage

Function Count_Links() Function Count_Links()

Dim oLink, Links, TotLinks Dim oLink, Links, TotLinks Set oL

Set oLink=Description.ink=Description.CreateCreate oLink("micclass").value="Link" oLink("micclass").value="Link" Set

Set Links=Browser("tLinks=Browser("title:=.*").Page("title:=.*").Citle:=.*").Page("title:=.*").ChildObjects(oLink)hildObjects(oLink) TotLinks=Links.count TotLinks=Links.count Next Next End Function End Function Call Count_Links() Call Count_Links() ---Function Count_Buttons() Function Count_Buttons()

Dim oButton, Buttons,TotButtons, i, myButton Dim oButton, Buttons,TotButtons, i, myButton Set

Set oButton=Description.oButton=Description.CreateCreate

oButton("Class Name").Value="WinButton" oButton("Class Name").Value="WinButton" Set

Set Buttons=Dialog("text:=LoginButtons=Dialog("text:=Login").ChildObjects(oButton)").ChildObjects(oButton) TotButtons=Buttons.count TotButtons=Buttons.count Msgbox TotButtons Msgbox TotButtons For i= 0 to TotButtons-1 For i= 0 to TotButtons-1 myButton=Buttons(i).Getroproperty("text") myButton=Buttons(i).Getroproperty("text") Msgbox myButton Msgbox myButton Next Next End Function End Function Call Count_Buttons() Call Count_Buttons() ---Function

Function Count_Objects(objCount_Objects(object)ect) Dim oobject,

Dim oobject, objects,Totobjectsobjects,Totobjects Set

Set oobject=Description.oobject=Description.CreateCreate oobject("Class Name").Value=object oobject("Class Name").Value=object Set

Set objects=Window("tobjects=Window("text:=Flight ext:=Flight Reservation").ChildObjects(Reservation").ChildObjects(oobject)oobject) Totobjects=objects.count Totobjects=objects.count Msgbox Totobjects Msgbox Totobjects End Function End Function Call

Call Count_objects(Count_objects("WinButton")"WinButton") Call

Call Count_objects(Count_objects("WinEdit")"WinEdit") Call

Call Count_objects(Count_objects("WinRadioButton")"WinRadioButton") Call

Call Count_objects(Count_objects("WinComboBox")"WinComboBox")

(3)

---Function Launch_App() Function Launch_App()

SystemUtil.Run "C:\Program Files\Internet SystemUtil.Run "C:\Program Files\Internet

Explorer\IEXPLORE.EXE","www.jjperfumes.com" Explorer\IEXPLORE.EXE","www.jjperfumes.com" Wait (8)

Wait (8)

Browser_Name =

Browser_Name = Browser("JJ Perfumes-DiscounBrowser("JJ Perfumes-Discount t perfume").GetROProperty(perfume").GetROProperty("title")"title") If

If Browser_Name= Browser_Name= "JJ Perfumes-Dis"JJ Perfumes-Discount perfume ccount perfume cheap brand name perheap brand name perfumes,fumes, fragrance & cologne online" Then

fragrance & cologne online" Then

Launch_App="Application Launched Sucessfully" Launch_App="Application Launched Sucessfully" Msgbox Launch_App

Msgbox Launch_App Else

Else

Launch_App="Application Not Launched" Launch_App="Application Not Launched" Msgbox Launch_App Msgbox Launch_App End If  End If  End Function End Function ---Function Registration(Email) Function Registration(Email) Set

Set myBrowser=BmyBrowser=Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-rowser("JJ Discount perfume").Page("JJ Perfumes-Discount perfume_2")

Discount perfume_2")

Browser("JJ Perfumes-Discount perfume").Page("JJ

Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-DiscounPerfumes-Discountt perfume").Link("Register").Click

perfume").Link("Register").Click myBrowser.WebList("u

myBrowser.WebList("usertype").Select sertype").Select "Retailer""Retailer" myBrowser.WebEdit(

myBrowser.WebEdit("firstname").Set "firstname").Set "utyyruy""utyyruy" myBrowser.WebEdit(

myBrowser.WebEdit("lastname").Set "lastname").Set "uyuu""uyuu" myBrowser.WebList("g

myBrowser.WebList("gender").Select ender").Select "Male""Male" myBrowser.WebEdit(

myBrowser.WebEdit("address1").Set "address1").Set "uyuytutuu""uyuytutuu" myBrowser.WebEdit(

myBrowser.WebEdit("phone").Set "phone").Set "9222222223""9222222223" myBrowser.WebEdit(

myBrowser.WebEdit("email").Set "email").Set EmailEmail myBrowser.WebEdit(

myBrowser.WebEdit("city").Set "city").Set "hyderabad""hyderabad" myBrowser.WebList("s

myBrowser.WebList("state").Select "MO - tate").Select "MO - MISSOURI"MISSOURI" myBrowser.WebList("s

myBrowser.WebList("state").Select "MT tate").Select "MT - MONTANA"- MONTANA" myBrowser.WebEdit( myBrowser.WebEdit("zip").Set "zip").Set "34567""34567" myBrowser.WebEdit("password").SetSecure myBrowser.WebEdit("password").SetSecure "3c30b5521a58241cf85aea528e1f4148a78f" "3c30b5521a58241cf85aea528e1f4148a78f" myBrowser.WebEdit("conPass").SetSecure myBrowser.WebEdit("conPass").SetSecure "3c30b557ccf6dbd1b0951c84b2fefb951f55" "3c30b557ccf6dbd1b0951c84b2fefb951f55" myBrowser.WebButton("Submit").Click myBrowser.WebButton("Submit").Click Confirm_Message =

Confirm_Message = Browser("JJ Perfumes-DiscounBrowser("JJ Perfumes-Discount t perfume").Page("JJ Perfumes-perfume").Page("JJ Perfumes-Discount

Discount perfume_3").WebElement(perfume_3").WebElement("Registered"Registered successfully.").GetROProperty("innertext") successfully.").GetROProperty("innertext")

If Confir

If Confirm_Message="Registered m_Message="Registered successfully. successfully. " " ThenThen Registration="Customer Registerd

Registration="Customer Registerd Sucessfully"Sucessfully" Msgbox Registration Msgbox Registration Else Else Registration="Registration Failed" Registration="Registration Failed" Msgbox Registration Msgbox Registration End If  End If  End Function End Function ---Function Login(Email, Password) Function Login(Email, Password)

Browser("JJ Perfumes-Discount perfume").Page("JJ

Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-DiscounPerfumes-Discountt perfume_3").Link("Login").Click

(4)

Browser("JJ Perfumes-Discount perfume").Page("JJ

Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-DiscounPerfumes-Discountt perfume_3").WebEdit("us

perfume_3").WebEdit("username").Set ername").Set EmailEmail

Browser("JJ Perfumes-Discount perfume").Page("JJ

Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-DiscounPerfumes-Discountt perfume_3").WebEdit("passw

perfume_3").WebEdit("password").SetSecure ord").SetSecure PasswordPassword Browser("JJ Perfumes-Discount perfume").Page("JJ

Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-DiscounPerfumes-Discountt perfume_3").WebButton("Login").Click

perfume_3").WebButton("Login").Click

If

If Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-DiscountBrowser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-Discount perfume_4").Link("Logout

perfume_4").Link("Logout").Exist(5) ").Exist(5) ThenThen Login="Login Operation Sucessful" Login="Login Operation Sucessful" Msgbox Login

Msgbox Login Else

Else

Login="Login Operation Failed" Login="Login Operation Failed"

Msgbox Login Msgbox Login End If  End If  End Function End Function

---Built in Functions

Built in Functions

---1) Asc Function 1) Asc Function Dim val Dim val val="Hyderabad" val="Hyderabad" Msgbox Asc(val) '72 Msgbox Asc(val) '72 Msgbox Asc("A") '65 Msgbox Asc("A") '65 Msgbox Asc("Z") '90 Msgbox Asc("Z") '90 Msgbox Asc("a") '97 Msgbox Asc("a") '97 Msgbox Asc("z") '122 Msgbox Asc("z") '122 Msgbox Asc(1) '49 Msgbox Asc(1) '49 Msgbox Asc("*") '42 Msgbox Asc("*") '42 2) Chr Function 2) Chr Function Dim val Dim val val=72 val=72 Msgbox Chr(val) 'H Msgbox Chr(val) 'H Msgbox Chr(65) 'A Msgbox Chr(65) 'A Msgbox Chr(90) 'Z Msgbox Chr(90) 'Z Msgbox Chr(97) 'a Msgbox Chr(97) 'a Msgbox Chr(122) 'z Msgbox Chr(122) 'z Msgbox Chr(49) '49 Msgbox Chr(49) '49 Msgbox Chr (42) '* Msgbox Chr (42) '* 3) Abs Function 3) Abs Function Dim val Dim val val=100.49 val=100.49 Msgbox Abs(val)' 100.49 Msgbox Abs(val)' 100.49 val=100.59 val=100.59 Msgbox Abs(val) '100.59 Msgbox Abs(val) '100.59 val=-100.49 val=-100.49

(5)

Msgbox Abs(val) '100.49 Msgbox Abs(val) '100.49 4) Round Function 4) Round Function Dim val Dim val val=100.49 val=100.49 Msgbox Round(val)' 100 Msgbox Round(val)' 100 val=100.59 val=100.59 Msgbox Round(val) '101 Msgbox Round(val) '101 val=-100.49 val=-100.49 Msgbox Round(val) '-100 Msgbox Round(val) '-100 val=-100.59 val=-100.59 Msgbox Round(val) '-101 Msgbox Round(val) '-101 val=100.5 val=100.5 Msgbox Round(val) '100 Msgbox Round(val) '100 5) IsArray 5) IsArray Dim a, b(3), c(), d(4,5) Dim a, b(3), c(), d(4,5) Msgbox IsArray(a) 'False Msgbox IsArray(a) 'False Msgbox IsArray(b) 'True Msgbox IsArray(b) 'True Msgbox IsArray(c) 'True Msgbox IsArray(c) 'True Msgbox IsArray(d) 'True Msgbox IsArray(d) 'True

6) IsNumeric 6) IsNumeric Dim val Dim val val=100 val=100

Msgbox IsNumeric(val) 'True Msgbox IsNumeric(val) 'True val=100.456

val=100.456

Msgbox IsNumeric(val) 'True Msgbox IsNumeric(val) 'True val="abcd"

val="abcd"

Msgbox IsNumeric(val) 'False Msgbox IsNumeric(val) 'False val="100"

val="100"

Msgbox IsNumeric(val) 'True Msgbox IsNumeric(val) 'True

val=#10/10/10# val=#10/10/10#

Msgbox IsNumeric(val) 'False Msgbox IsNumeric(val) 'False

7) IsDate 7) IsDate Dim val Dim val val=#10-10-10# val=#10-10-10#

Msgbox IsDate(val) 'True Msgbox IsDate(val) 'True

val=#10-10-2010# val=#10-10-2010# Msgbox IsDate(val) 'True Msgbox IsDate(val) 'True

val=#10/10/2010# val=#10/10/2010# Msgbox IsDate(val) 'True Msgbox IsDate(val) 'True

val=#20/10/2010# val=#20/10/2010#

(6)

Msgbox IsDate(val) 'True Msgbox IsDate(val) 'True

'val=#20/20/10# 'val=#20/20/10#

'Msgbox IsDate(val) 'Error 'Msgbox IsDate(val) 'Error

val=#10/40/10# val=#10/40/10#

Msgbox IsDate(val) 'Error Msgbox IsDate(val) 'Error

val=#Sep/20/10# val=#Sep/20/10#

Msgbox IsDate(val) 'True Msgbox IsDate(val) 'True

val=100 val=100

Msgbox IsDate(val) 'False Msgbox IsDate(val) 'False

val="asdd" val="asdd"

Msgbox IsDate(val) 'False Msgbox IsDate(val) 'False

8) IsEmpty 8) IsEmpty Dim x,y Dim x,y x=100 x=100

Msgbox IsEmpty(x) 'False Msgbox IsEmpty(x) 'False Msgbox IsEmpty(y) 'True Msgbox IsEmpty(y) 'True y="abcd"

y="abcd"

Msgbox IsEmpty(y) 'False Msgbox IsEmpty(y) 'False

y=0 y=0

Msgbox IsEmpty(y) 'False Msgbox IsEmpty(y) 'False

y=Empty y=Empty

Msgbox IsEmpty(y) 'True Msgbox IsEmpty(y) 'True

9) Array 9) Array

Dim x,y Dim x,y

Msgbox IsArray(x) 'False Msgbox IsArray(x) 'False

x=Array("abcd",100, #10-10-10#) x=Array("abcd",100, #10-10-10#) Msgbox IsArray(x) 'True

Msgbox IsArray(x) 'True

Msgbox x(1) '100 Msgbox x(1) '100 10) Split 10) Split Dim x,y Dim x,y x="VB Script Language" x="VB Script Language" Msgbox IsArray(y) 'False Msgbox IsArray(y) 'False y=Split(x," ")

y=Split(x," ")

Msgbox IsArray(y) 'True Msgbox IsArray(y) 'True

Msgbox y(1) 'Script Msgbox y(1) 'Script

11) DateDiff  11) DateDiff 

(7)

Dim Date1, Date2 Dim Date1, Date2 Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-07# Date2=#10-10-07# Msgbox DateDiff("d",Date1,Date2) Msgbox DateDiff("d",Date1,Date2) Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("d",Date1,Date2) &" Days" Msgbox DateDiff("d",Date1,Date2) &" Days"

Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("m",Date1,Date2) &" Months" Msgbox DateDiff("m",Date1,Date2) &" Months"

Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("y",Date1,Date2) &" Days" Msgbox DateDiff("y",Date1,Date2) &" Days"

Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("yyyy",Date1,Date2) &" Years" Msgbox DateDiff("yyyy",Date1,Date2) &" Years"

Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("w",Date1,Date2) &" Weeks" Msgbox DateDiff("w",Date1,Date2) &" Weeks"

Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("q",Date1,Date2) &" Quarters" Msgbox DateDiff("q",Date1,Date2) &" Quarters"

Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("h",Date1,Date2) &" Hours" Msgbox DateDiff("h",Date1,Date2) &" Hours"

Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("n",Date1,Date2) &" Minutes" Msgbox DateDiff("n",Date1,Date2) &" Minutes"

Date1=#10-10-09# Date1=#10-10-09# Date2=#10-10-11# Date2=#10-10-11#

Msgbox DateDiff("s",Date1,Date2) &" Seconds" Msgbox DateDiff("s",Date1,Date2) &" Seconds"

12) Len Function 12) Len Function Dim val Dim val val="Hyderabad" val="Hyderabad" Msgbox Len(val) '9 Msgbox Len(val) '9 Msgbox

Msgbox Len Len ("asd1234") ("asd1234") '7'7

Msgbox

Msgbox Len Len (1000) (1000) '4'4

Msgbox

(8)

Msgbox

Msgbox Len Len ("#10-10-10#") ("#10-10-10#") '10'10

Msgbox

Msgbox Len Len (#Sep-10-10#) (#Sep-10-10#) '9'9 Msgbox

Msgbox Len Len (#Dec-10-10#) (#Dec-10-10#) '10'10

13) Left Function 13) Left Function Dim val Dim val val="Hyderabad" val="Hyderabad"

Msgbox Left(val,3) 'Hyd Msgbox Left(val,3) 'Hyd

Msgbox Left(9247892478,1) '9 Msgbox Left(9247892478,1) '9 Msgbox Left("%*&y",2) '%* Msgbox Left("%*&y",2) '%* 14) Right Function 14) Right Function Dim val Dim val val="Hyderabad" val="Hyderabad"

Msgbox Right(val,3) 'bad Msgbox Right(val,3) 'bad

Msgbox Right(9247892478,1) '8 Msgbox Right(9247892478,1) '8

Msgbox Right("%*&y",2) '&y Msgbox Right("%*&y",2) '&y

15) Mid Function 15) Mid Function Dim val Dim val val="Hyderabad" val="Hyderabad"

Msgbox Mid(val,3) 'bad Msgbox Mid(val,3) 'bad

Msgbox Mid(9247892478,5,2) '89 Msgbox Mid(9247892478,5,2) '89

Msgbox Mid("%*&y",2) '*&y Msgbox Mid("%*&y",2) '*&y

Msgbox Mid(#10-10-10#,4,5) '10/20 Msgbox Mid(#10-10-10#,4,5) '10/20 ---Dim x Dim x x="Hyderabad" x="Hyderabad"

Msgbox Left(x,3) 'Hyd Msgbox Left(x,3) 'Hyd Msgbox Mid(x,1,3) 'Hyd Msgbox Mid(x,1,3) 'Hyd

Msgbox Right (x,3) 'bad Msgbox Right (x,3) 'bad Msgbox Mid (x,7)

Msgbox Mid (x,7)

Msgbox Mid(x,5,3) 'rab Msgbox Mid(x,5,3) 'rab ---16) StrComp Function 16) StrComp Function Result Criteria: Result Criteria:

(9)

---a) If st1>str2 then it returns 1 a) If st1>str2 then it returns 1

a) If st1<str2 then it

a) If st1<str2 then it returns -1returns -1 a) If st1=str2 then it returns 0 a) If st1=str2 then it returns 0 Dim val1,val2 Dim val1,val2 val1=100 val1=100 val2=100 val2=100 Msgbox StrComp(val1,val2) '0 Msgbox StrComp(val1,val2) '0 val1="QTP" val1="QTP" val2="qtp" val2="qtp" Msgbox StrComp(val1,val2,0) '-1 Msgbox StrComp(val1,val2,0) '-1 val1="qtp" val1="qtp" val2="QTP" val2="QTP" Msgbox StrComp(val1,val2,0) '1 Msgbox StrComp(val1,val2,0) '1 val1="QTP" val1="QTP" val2="qtp" val2="qtp" Msgbox StrComp(val1,val2,1) '0 Msgbox StrComp(val1,val2,1) '0 ---17) Cdbl Function 17) Cdbl Function Dim val Dim val val="100.45" val="100.45"

Msgbox VarType(val) '8 for String Msgbox VarType(val) '8 for String

val=Cdbl(val) val=Cdbl(val)

Msgbox VarType(val) '5 for Double Msgbox VarType(val) '5 for Double

18) CInt Function 18) CInt Function Dim val Dim val val="100" val="100"

Msgbox VarType(val) '8 for String Msgbox VarType(val) '8 for String

val=CInt (val) val=CInt (val)

Msgbox VarType(val) '2 for Integer Msgbox VarType(val) '2 for Integer

val="100.45" val="100.45"

Msgbox VarType(val) '8 for String Msgbox VarType(val) '8 for String Msgbox val

Msgbox val

val=CInt (val) val=CInt (val)

Msgbox VarType(val) '2 for Integer Msgbox VarType(val) '2 for Integer Msgbox val Msgbox val 19) VarType Function 19) VarType Function Dim val, x Dim val, x val="Hyderabad" val="Hyderabad"

Msgbox VarType(val) '8 for String Msgbox VarType(val) '8 for String

val="100" val="100"

(10)

Msgbox VarType(val) '8 for String Msgbox VarType(val) '8 for String

val="100.456" val="100.456"

Msgbox VarType(val) '8 for String Msgbox VarType(val) '8 for String

val=100 val=100

Msgbox VarType(val) '2 for Integer Msgbox VarType(val) '2 for Integer

val=100.456 val=100.456

Msgbox VarType(val) '5 for Double Msgbox VarType(val) '5 for Double

Msgbox VarType(x) '0 for Uninitialized Msgbox VarType(x) '0 for Uninitialized

Msgbox VarType(#10/10/2010#) '7 for Date

Msgbox VarType(#10/10/2010#) '7 for Date formatformat

Set

Set x=CreateObject("Sx=CreateObject("Scripting.FileSystemObject")cripting.FileSystemObject") Msgbox VarType(x) '9 for Automation Object

Msgbox VarType(x) '9 for Automation Object

20) LCase Function 20) LCase Function Dim val Dim val val="HYDERABAD" val="HYDERABAD"

Msgbox LCase(val) 'hyderabad Msgbox LCase(val) 'hyderabad

val="HyderABAD" val="HyderABAD"

Msgbox LCase(val) 'hyderabad Msgbox LCase(val) 'hyderabad

val="hyderabad" val="hyderabad"

Msgbox LCase(val) 'hyderabad Msgbox LCase(val) 'hyderabad

val="100" val="100" Msgbox LCase(val) '100 Msgbox LCase(val) '100 val=100 val=100 Msgbox LCase(val) '100 Msgbox LCase(val) '100 21) UCase Function 21) UCase Function Dim val Dim val val="HYDERABAD" val="HYDERABAD"

Msgbox UCase(val) 'HYDERABAD Msgbox UCase(val) 'HYDERABAD

val="HyderABAD" val="HyderABAD"

Msgbox UCase(val) 'HYDERABAD Msgbox UCase(val) 'HYDERABAD

val="hyderabad" val="hyderabad"

Msgbox UCase(val) 'HYDERABAD Msgbox UCase(val) 'HYDERABAD

val="100" val="100" Msgbox UCase(val) '100 Msgbox UCase(val) '100 val=100 val=100 Msgbox UCase(val) '100 Msgbox UCase(val) '100

(11)

22) Trim Function 22) Trim Function 23) LTrim Function 23) LTrim Function 24) RTrim Function 24) RTrim Function Dim val Dim val val="

val=" vb vb script script "" Msgbox val

Msgbox val

Msgbox Trim(val) Msgbox Trim(val)

val="

val=" vb vb script script "" Msgbox val

Msgbox val

Msgbox LTrim(val) Msgbox LTrim(val)

val="

val=" vb vb script script "" Msgbox val Msgbox val Msgbox RTrim(val) Msgbox RTrim(val) 25) Date Function 25) Date Function 26) Time Function 26) Time Function 27) Now Function 27) Now Function Dim val Dim val val=Date val=Date Msgbox val Msgbox val val=Time val=Time Msgbox val Msgbox val val=Now val=Now Msgbox val Msgbox val

val= Date&" "&Time val= Date&" "&Time Msgbox val

Msgbox val

val= Time&" "&Date val= Time&" "&Date Msgbox val Msgbox val 28) Timer Function 28) Timer Function Variable1=Timer Variable1=Timer ---Statements Statements - ---Variable2=Timer Variable2=Timer Variable3=Variable2-Variable1 Variable3=Variable2-Variable1 Ex: Ex:

(12)

Start_Transaction=Timer Start_Transaction=Timer SystemUtil.Run "C:\Program

SystemUtil.Run "C:\Program Files\HP\QuickTFiles\HP\QuickTestest Professional\samples\f

Professional\samples\flight\app\flight4a.exe","","C:\Progrlight\app\flight4a.exe","","C:\Program am Files\HP\QuickTFiles\HP\QuickTestest Professional\samples\flight\app\","open" Professional\samples\flight\app\","open" Dialog("Login").Activate Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set "dfgh" Dialog("Login").WinEdit("Agent Name:").Set "dfgh" Dialog("Login").WinEdit("Password:").SetSecure Dialog("Login").WinEdit("Password:").SetSecure "3c30b6b7c56ffcb6847571203c0da519da6af43e" "3c30b6b7c56ffcb6847571203c0da519da6af43e" Dialog("Login").WinButton("OK").Click Dialog("Login").WinButton("OK").Click Window("Flight Reservation").Close Window("Flight Reservation").Close End_Transaction=Timer End_Transaction=Timer Transaction_Time=End_Transaction-Start_Transaction Transaction_Time=End_Transaction-Start_Transaction Msgbox Transaction_Time Msgbox Transaction_Time 29) CreateObject Function 29) CreateObject Function Dim objFso Dim objFso

'Creating an Automation Object in File System Object , that can be used to perform 'Creating an Automation Object in File System Object , that can be used to perform Operations on Computer File System

Operations on Computer File System Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject")

Dim objExcel Dim objExcel

'Creating an Automation Object in Excel Application , that can be used to perform 'Creating an Automation Object in Excel Application , that can be used to perform Operations on Excel Files

Operations on Excel Files Set

Set objExcel=CreateObjobjExcel=CreateObject("Excel.Application")ect("Excel.Application")

Dim objWord Dim objWord

'Creating an Automation Object in Word Application , that can be used to perform 'Creating an Automation Object in Word Application , that can be used to perform Operations on Word Documents

Operations on Word Documents Set

Set objWord=CreateObject(objWord=CreateObject("Word.Application")"Word.Application")

Dim objDic Dim objDic

'Creating an Automation Object in Dictionary Object, that can be used to define key, 'Creating an Automation Object in Dictionary Object, that can be used to define key, value pairs

value pairs Set

Set objDic=CreateObject(objDic=CreateObject("Scripting.Dictionary")"Scripting.Dictionary")

Dim objCon Dim objCon

'Creating an Automation Object in Database Connection , that can be used to 'Creating an Automation Object in Database Connection , that can be used to connect to Databases

connect to Databases Set

Set objCon=CreateObjectobjCon=CreateObject("Adodb.Connection")("Adodb.Connection")

Dim objRs Dim objRs

'Creating an Automation Object in Database RecordSet , that can be used to perform 'Creating an Automation Object in Database RecordSet , that can be used to perform Operations on Database Tables

Operations on Database Tables Set

Set objRs=CreateObject(objRs=CreateObject("Adodb.RecordSet")"Adodb.RecordSet")

Dim objCom Dim objCom

'Creating an Automation Object in Database Command , that can be used to 'Creating an Automation Object in Database Command , that can be used to Maniplate Databases

Maniplate Databases Set

Set objCom=CreateObjectobjCom=CreateObject("Adodb.Command")("Adodb.Command") ---Examples: Examples:

(13)

---'Create a Folder 'Create a Folder

Dim objFso Dim objFso Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") objFso.CreateFolder "C:\Documents and

objFso.CreateFolder "C:\Documents and Settings\Administrator\DSettings\Administrator\Desktop\abc"esktop\abc"

'Check the Existance of a Folder , if not exist then Create the Folder 'Check the Existance of a Folder , if not exist then Create the Folder Dim objFso, myFolder

Dim objFso, myFolder myFolder="C:\Doc

myFolder="C:\Documents uments and and Settings\AdministratorSettings\Administrator\Desktop\abc"\Desktop\abc" Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") If Not

If Not objFso.FolderobjFso.FolderExists(myFolder) Exists(myFolder) ThenThen objFso.CreateFold

objFso.CreateFolder er (myFolder)(myFolder) End If 

End If 

'Copy a folder 'Copy a folder

Dim objFso, myFolder Dim objFso, myFolder myFolder="C:\Doc

myFolder="C:\Documents uments and and Settings\AdministratorSettings\Administrator\Desktop\November"\Desktop\November" Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") objFso.CopyFolder myFolder, "C:\Documents and

objFso.CopyFolder myFolder, "C:\Documents and Settings\AdministrSettings\Administrator\Myator\My Documents\December"

Documents\December"

'Delete a folder 'Delete a folder

Dim objFso, myFolder Dim objFso, myFolder myFolder="C:\Doc

myFolder="C:\Documents uments and and Settings\AdministratorSettings\Administrator\Desktop\November"\Desktop\November" Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") objFso.DeleteFolder(myFolder)

objFso.DeleteFolder(myFolder)

'Delete a folder 'Delete a folder

Dim objFso, myFolder Dim objFso, myFolder myFolder="C:\Doc

myFolder="C:\Documents uments and and Settings\AdministratorSettings\Administrator\Desktop\November"\Desktop\November" Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") If

If objFso.FolderEobjFso.FolderExists(myFolder) xists(myFolder) ThenThen objFso.DeleteFolder(myFolder)

objFso.DeleteFolder(myFolder) End If 

End If 

''Create a Flat file ''Create a Flat file Dim objFso

Dim objFso Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") objFso.CreateTextFile(

objFso.CreateTextFile("C:\Documents "C:\Documents and and Settings\Administrator\Settings\Administrator\Desktop\abc.txt")Desktop\abc.txt")

objFso.CreateTextFile(

objFso.CreateTextFile("C:\Documents "C:\Documents and and Settings\Administrator\Settings\Administrator\Desktop\abc.doc")Desktop\abc.doc") objFso.CreateTextFile(

objFso.CreateTextFile("C:\Documents "C:\Documents and and Settings\Administrator\Settings\Administrator\Desktop\abc.xls")Desktop\abc.xls") objFso.CreateTextFile(

objFso.CreateTextFile("C:\Documents "C:\Documents and and Settings\Administrator\Settings\Administrator\Desktop\abc.pdf")Desktop\abc.pdf")

'Write Data to a Text file 'Write Data to a Text file ''Create a Flat file

''Create a Flat file Dim objFso, myFile Dim objFso, myFile Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") Set

Set myFile=objFsmyFile=objFso.OpenTextFile("C:\Documo.OpenTextFile("C:\Documents ents andand Settings\Administrator\D

Settings\Administrator\Desktop\abc.txt",2) '1-Read, 2-Write, esktop\abc.txt",2) '1-Read, 2-Write, 8- Append8- Append Result=10+23

Result=10+23

myFile.WriteLine "Result is: " &Result myFile.WriteLine "Result is: " &Result myFile.Close

(14)

Set objFso=Nothing Set objFso=Nothing

---'Caputure Buttons Name fro Login Dialog box and Export to an external flat file 'Caputure Buttons Name fro Login Dialog box and Export to an external flat file Dim objFso, myFile, oButton

Dim objFso, myFile, oButton Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") Set

Set myFile=objFsmyFile=objFso.OpenTextFile("C:\Documo.OpenTextFile("C:\Documents ents andand Settings\Administrator\D

Settings\Administrator\Desktop\abc.txt",2) '1-Read, 2-Write, esktop\abc.txt",2) '1-Read, 2-Write, 8- Append8- Append myFile.WriteLine "Button Names"

myFile.WriteLine "Button Names" myFile.WriteLine

myFile.WriteLine "---"---"---" Set

Set oButton=DescriptoButton=Description.Createion.Create

oButton("Class Name").value="WinButton" oButton("Class Name").value="WinButton" Set

Set Buttons=Dialog("text:Buttons=Dialog("text:=Login").ChildObjects(oBu=Login").ChildObjects(oButton)tton) TotButtons=Buttons.Count

TotButtons=Buttons.Count For i= 0 to

For i= 0 to TotButtons-1TotButtons-1

myButton=Buttons(i).GetRoProperty("text") myButton=Buttons(i).GetRoProperty("text") myFile.WriteLine myButton myFile.WriteLine myButton Next Next myFile.Close myFile.Close Set objFso=Nothing Set objFso=Nothing

---'Caputure Buttons Name fro Login Dialog box and Export to an external flat file 'Caputure Buttons Name fro Login Dialog box and Export to an external flat file Dim objFso, myFile, oButton

Dim objFso, myFile, oButton Set

Set objFso=CreateObjobjFso=CreateObject("Scripting.FileSystect("Scripting.FileSystemObject")emObject") Set

Set myFile=objFsmyFile=objFso.OpenTextFile("C:\Documo.OpenTextFile("C:\Documents ents andand Settings\Administrator\D

Settings\Administrator\Desktop\abc.txt",2) '1-Read, 2-Write, esktop\abc.txt",2) '1-Read, 2-Write, 8- Append8- Append myFile.WriteLine "Customer Names"

myFile.WriteLine "Customer Names" myFile.WriteLine

myFile.WriteLine "---"---"---" If Not

If Not Window("Flight Window("Flight Reservation").Exist(Reservation").Exist(3) 3) ThenThen SystemUtil.Run "C:\Program

SystemUtil.Run "C:\Program Files\HP\QuickTFiles\HP\QuickTestest Professional\samples\f

Professional\samples\flight\app\flight4a.exe","","C:\Progrlight\app\flight4a.exe","","C:\Program am Files\HP\QuickTFiles\HP\QuickTestest Professional\samples\flight\app\","open"

Professional\samples\flight\app\","open" Dialog("Login").Activate

Dialog("Login").Activate

Dialog("Login").WinEdit("Agent Name:").Set "yetyyt" Dialog("Login").WinEdit("Agent Name:").Set "yetyyt" Dialog("Login").WinEdit("Password:").SetSecure Dialog("Login").WinEdit("Password:").SetSecure "3c30cae3f35fe9752b50e9b98a5efed3e96b7fc7" "3c30cae3f35fe9752b50e9b98a5efed3e96b7fc7" Dialog("Login").WinButton("OK").Click Dialog("Login").WinButton("OK").Click End If  End If  For i =1 to 10 Step 1 For i =1 to 10 Step 1 Window("Flight Reservation").Activate Window("Flight Reservation").Activate Window("Flight

Window("Flight Reservation").WinButton(Reservation").WinButton("Button").Click"Button").Click Window("Flight Reservation").Dialog("Open

Window("Flight Reservation").Dialog("Open Order").WinCheckBoxOrder").WinCheckBox("Order No.").Set("Order No.").Set "ON"

"ON"

Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i Window("Flight Reservation").Dialog("Open

Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Order").WinButton("OK").ClickClick wait (1) wait (1) Customer_Name = Window("Flight Customer_Name = Window("Flight Reservation").WinEdit("Name:").GetROProperty("text") Reservation").WinEdit("Name:").GetROProperty("text") myFile.WriteLine Customer_Name myFile.WriteLine Customer_Name Next Next myFile.Close myFile.Close

(15)

Set objFso=Nothing Set objFso=Nothing

References

Related documents