Looping statements are used to run the same block of code a specified number of times.
In VBScript we have four looping statements:
For...Next statement - runs code a specified number of times
For Each...Next statement - runs code for each item in a collection or each element of an array
Do...Loop statement - loops while or until a condition is true
While...Wend statement - Do not use it - use the Do...Loop statement instead
Tuesday, July 20, 2010
Important Datetime functions
msgbox day(now())
msgbox weekdayname(weekday(now()))
or
msgbox weekdayname (weekday(day(now())))
msgbox monthname(month(now()))
msgbox year(now())
msgbox hour(now)
msgbox minute(now)
msgbox Second(now)
msgbox weekdayname(weekday(now()))
or
msgbox weekdayname (weekday(day(now())))
msgbox monthname(month(now()))
msgbox year(now())
msgbox hour(now)
msgbox minute(now)
msgbox Second(now)
reading environment variable values from the excel vba
Environ Function
Returns the String associated with an operating system environment variable. Not available on the Macintosh
Syntax
Environ({envstring | number})
The Environ function syntax has these named arguments:
Part Description
envstring Optional. String expression containing the name of an environment variable.
number Optional. Numeric expression corresponding to the numeric order of the environment string in the environment-string table. The number argument can be any numeric expression, but is rounded to a whole number before it is evaluated.
Remarks
If envstring can't be found in the environment-string table, a zero-length string ("") is returned. Otherwise, Environ returns the text assigned to the specified envstring; that is, the text following the equal sign (=) in the environment-string table for that environment variable.
If you specify number, the string occupying that numeric position in the environment-string table is returned. In this case, Environ returns all of the text, including envstring. If there is no environment string in the specified position, Environ returns a zero-length string.
Sub List_Environment_Variables()
Dim EnvString As String
Indx = 1
Do
EnvString = Environ(Indx)
Cells(Indx, 1) = EnvString
Indx = Indx + 1
Loop Until EnvString = ""
End Sub
ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\nbdyvek\Application Data
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=B0024811EE6F0
ComSpec=C:\WINNT\system32\cmd.exe
DEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\nbdyvek
LOGONSERVER=\\ASIGGNDCS00
LSERVRC=C:\Program Files\Common Files\Mercury Interactive\License Manager\lservrc
LSHOST=172.23.3.194
NUMBER_OF_PROCESSORS=4
OS=Windows_NT
Path=C:\Program Files\Microsoft Office\Office12\;c:\Program Files\oracle\product\10.2.0\client_1\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;"C:\Program Files\PKWARE\pkzipc"
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=170a
ProgramFiles=C:\Program Files
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINNT
TEMP=C:\DOCUME~1\nbdyvek\LOCALS~1\Temp
TMP=C:\DOCUME~1\nbdyvek\LOCALS~1\Temp
USERDNSDOMAIN=ASIA.BANKOFAMERICA.COM
USERDOMAIN=ASIA
USERNAME=nbdyvek
USERPROFILE=C:\Documents and Settings\nbdyvek
VSEDEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
WecVersionForRosebud.E88=3
windir=C:\WINNT
Returns the String associated with an operating system environment variable. Not available on the Macintosh
Syntax
Environ({envstring | number})
The Environ function syntax has these named arguments:
Part Description
envstring Optional. String expression containing the name of an environment variable.
number Optional. Numeric expression corresponding to the numeric order of the environment string in the environment-string table. The number argument can be any numeric expression, but is rounded to a whole number before it is evaluated.
Remarks
If envstring can't be found in the environment-string table, a zero-length string ("") is returned. Otherwise, Environ returns the text assigned to the specified envstring; that is, the text following the equal sign (=) in the environment-string table for that environment variable.
If you specify number, the string occupying that numeric position in the environment-string table is returned. In this case, Environ returns all of the text, including envstring. If there is no environment string in the specified position, Environ returns a zero-length string.
Sub List_Environment_Variables()
Dim EnvString As String
Indx = 1
Do
EnvString = Environ(Indx)
Cells(Indx, 1) = EnvString
Indx = Indx + 1
Loop Until EnvString = ""
End Sub
ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\nbdyvek\Application Data
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=B0024811EE6F0
ComSpec=C:\WINNT\system32\cmd.exe
DEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\nbdyvek
LOGONSERVER=\\ASIGGNDCS00
LSERVRC=C:\Program Files\Common Files\Mercury Interactive\License Manager\lservrc
LSHOST=172.23.3.194
NUMBER_OF_PROCESSORS=4
OS=Windows_NT
Path=C:\Program Files\Microsoft Office\Office12\;c:\Program Files\oracle\product\10.2.0\client_1\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;"C:\Program Files\PKWARE\pkzipc"
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=170a
ProgramFiles=C:\Program Files
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINNT
TEMP=C:\DOCUME~1\nbdyvek\LOCALS~1\Temp
TMP=C:\DOCUME~1\nbdyvek\LOCALS~1\Temp
USERDNSDOMAIN=ASIA.BANKOFAMERICA.COM
USERDOMAIN=ASIA
USERNAME=nbdyvek
USERPROFILE=C:\Documents and Settings\nbdyvek
VSEDEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
WecVersionForRosebud.E88=3
windir=C:\WINNT
Connecting to MS Access DataBase using QTP
Dim rs,con
set con = createobject("adodb.connection")
set rs = createobject("adodb.recordset")
con.provider = "microsoft.jet.oledb.4.0"
con.open "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb"
rs.open "select * from Orders where Flight_Number=4219 ",con
'to know the number of orders in class1
'rs.open "select count(*) from Orders group by class",con
'to insert into database
rs.open "insert into emp(empno,empname,empsal) values (4,'lakshmi',400),con
'display each field in the record set
Do while not rs.eof
For Each Field In rs.Fields
MsgBox Field.name
MsgBox Field.value
Next
rs.MoveNext
Loop
' Close the connection.
con.Close
set con = createobject("adodb.connection")
set rs = createobject("adodb.recordset")
con.provider = "microsoft.jet.oledb.4.0"
con.open "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb"
rs.open "select * from Orders where Flight_Number=4219 ",con
'to know the number of orders in class1
'rs.open "select count(*) from Orders group by class",con
'to insert into database
rs.open "insert into emp(empno,empname,empsal) values (4,'lakshmi',400),con
'display each field in the record set
Do while not rs.eof
For Each Field In rs.Fields
MsgBox Field.name
MsgBox Field.value
Next
rs.MoveNext
Loop
' Close the connection.
con.Close
How to select radio buttons
For a Windows radio button which is not in a group the following is the syntax:
"Set" method : sets the radio button as the selected radio button.
Window("Flight Reservation").WinRadioButton("Business").Set
For a Windows radio button which is in a group the following is the syntax:
Select Selects the specified radio button from the radio group, replacing the previous selection.
e.g.Browser("Google").Page("Google").WebRadioGroup("meta").Select "cr=countryIN"
"Set" method : sets the radio button as the selected radio button.
Window("Flight Reservation").WinRadioButton("Business").Set
For a Windows radio button which is in a group the following is the syntax:
Select Selects the specified radio button from the radio group, replacing the previous selection.
e.g.Browser("Google").Page("Google").WebRadioGroup("meta").Select "cr=countryIN"
Wednesday, July 14, 2010
Difference between Updated Run Mode & Maintenance Run Mode?
Update Run mode updates all properties of objects and checkpoints in case of failures. So if a object gets recognized using SMart identification then correct properties are updated in the OR. In case expected and actual values of checkpoints are different then they are updated as per the actuals.It can be selected from Automation -> Update Run mode
Maintenance run mode is used when you want to update objects which are failing during execution. So if the object cannot be recognized at all with current settings instead of giving an error QTP will give a dialog to point the object to a new object if required.
Sunday, July 4, 2010
What is the Automation Framework ?
A framework is an integrated system or an execution environment that sets the rules of Automation of a specific product.
The framework provides the basis of test automation and simplifies the automation effort.
This system integrates the function libraries, test data sources, object details and various reusable modules. These components act as small building blocks which need to be assembled to represent a business process.
There are various types of frameworks. They are categorized on the basis of the automation component they leverage. These are:
Data-driven testing :
Testing of application with multiple sets of data.The disadvatage with this framework is its Application dependent scripts.
Keyword-driven testing :
Keyword-driven testing: In Keyword Driven Framework every keyword represents some code which will perform certain action on the application.We create the excel file in which we provide the steps in simple english words (Keywords) by the user.
Advantage:The advantages for automated tests are the reusability and therefore ease of maintenance of tests that have been created at a high level of abstraction.
Disadvantage: Even for small actions in test Data file we need to write multiple lines to achieve the functionality.
Action Driven framework:
It takes the advantages for the Data Driven and Keyword Driven framework and automates thte application.Every Action here means a specific script which will perform only certain action provided the data in test data file.In RealTime people often call this Hybrid testing.
Hybrid testing :
The hybrid Test Automation Framework is what most frameworks evolve into over time and multiple projects. The most successful automation frameworks generally accommodate both Keyword-driven testing as well as Data-driven testing. This allows data driven scripts to take advantage of the powerful libraries and utilities that usually accompany a keyword driven architecture
The framework provides the basis of test automation and simplifies the automation effort.
This system integrates the function libraries, test data sources, object details and various reusable modules. These components act as small building blocks which need to be assembled to represent a business process.
There are various types of frameworks. They are categorized on the basis of the automation component they leverage. These are:
Data-driven testing :
Testing of application with multiple sets of data.The disadvatage with this framework is its Application dependent scripts.
Keyword-driven testing :
Keyword-driven testing: In Keyword Driven Framework every keyword represents some code which will perform certain action on the application.We create the excel file in which we provide the steps in simple english words (Keywords) by the user.
Advantage:The advantages for automated tests are the reusability and therefore ease of maintenance of tests that have been created at a high level of abstraction.
Disadvantage: Even for small actions in test Data file we need to write multiple lines to achieve the functionality.
Action Driven framework:
It takes the advantages for the Data Driven and Keyword Driven framework and automates thte application.Every Action here means a specific script which will perform only certain action provided the data in test data file.In RealTime people often call this Hybrid testing.
Hybrid testing :
The hybrid Test Automation Framework is what most frameworks evolve into over time and multiple projects. The most successful automation frameworks generally accommodate both Keyword-driven testing as well as Data-driven testing. This allows data driven scripts to take advantage of the powerful libraries and utilities that usually accompany a keyword driven architecture
What is Test Automation ?
Although manual tests may find many defects in a software application, it is a laborious and time consuming process. In addition it may not be effective in finding certain classes of defects. Test automation is a process of writing a computer program to do testing that would otherwise need to be done manually. Once tests have been automated, they can be run quickly. This is often the most cost effective method for software products that have a long maintenance life, because even minor patches over the lifetime of the application can cause features to break which were working at an earlier point in time.
Do you prefer to work alone or as a team ?
I would like to work in an environment where there are both the sides.
Its great working with team and sharing the knowledge, and learning ideas with each other.
It's also great to sit at my own desk and work independently towards team goal.
Its great working with team and sharing the knowledge, and learning ideas with each other.
It's also great to sit at my own desk and work independently towards team goal.
Subscribe to:
Posts (Atom)