Thursday, December 24, 2009

3rd Generation Frameworks : Keyword-driven

Third Generation frameworks are the most defined frameworks, and should be considered when the automation scope is relatively high, and when at least one of the automation resources has strong technical and logical skills, and a proficiency in the automation tool being used to develop the framework. The two frameworks that fit into this generation include Keyword-driven and Model-based frameworks.

Model-based PDF Print E-mail

Often called an “Intelligent framework”, Model-based frameworks go beyond creating automated tests that are executed by the tool. These frameworks are typically “given” information about the application, and the framework “creates” and executes tests in a semi-intelligent manner. Test automators describe the features of an application, typically through state models which depict the basic actions that may be performed on the application, as well as the broad expected reactions. Armed with this information the framework dynamically implements tests on the application.


Model-based Pros

* Increased coverage overtime – With a minimal amount of scripting, a lot of the application may be tested. The coverage may not necessarily be extremely high per execution, but given the random nature of the testing, the application test coverage will increase over time.
* Increased application exploration – Test automation is typically created to perform a specific set of test sequences with each test execution. Model-based test automation frameworks contain a certain degree of artificial intelligence, which allows it to perform an almost exploratory type of testing, in a way that is similar to how a manual tester might explore the application.
* Increased potential for defects discovery – Test automation is normally not meant to uncover a lot of new defects. Test automation is normally used to ensure existing functionality still works. The exploratory nature of Model-based frameworks, however, increase the chances of new defects being uncovered, given the fact that new ground is covered with each automated test run.


Model-based Challenges (Con)

* Requires higher degree of application knowledge – In order to maintain Model-based frameworks, a higher degree of application knowledge is required. This is directly related to the fact that there is less maintenance of automated tests (which is largely a technical activity), and more maintenance of application models that define application behavior.
* Required technical expertise – The technical skills required to create and maintain Model-based frameworks is relatively high. There are numerous dependencies and relationships that must be understood and maintained, as well as advanced tool components and structures.
* Increased management support – Management support is probably the most challenging with Model-based frameworks. Mainly because it is a lot simpler to calculate and communicate ROI with other frameworks. Model-based ROI calculations will more than likely be based largely on risks. Risk ROI calculations alone are often very difficult to convey to management as a justification for the time and resources necessary for creating and maintaining the structures, documentation, and personnel (both technical and non-technical).

Keyword-driven PDF Print E-mail

Often called “Table-driven”, this framework tends to be more application-independent than other frameworks. This framework processes automated tests that are developed in data tables with a vocabulary of Keywords (aka. 'Action' words) that are independent of the automated test tool used to execute them.


Screen Object Action Value Recovery Comment
LoginScreen Username Input “John”
LoginScreen Password Input “JPass”
LoginScreen Login Click
Welcome Verify_Screen Abort_Test



The keywords are associated with application-specific and application-independent functions and scripts that interpret the keyword data tables along with its application-specific data parameters. The automated scripts function as Drivers to execute the interpreted statements in the application under test.


1 Open Keyword File
2 Execute Data rows to end of file (EOF)
3 If == Input Then
4 Call Input function with Screen, Object and Value parameters
5 If == Click Then
6 Call Click function with Screen and Object parameters
7 If == Verify_Screen Then
8 Execute Verify_Screen function with Screen parameter
9 Implement Exception Handling Routine Based on Pass/Fail Status
10 End Loop


Keyword Driven frameworks rely heavily on Functional Decomposition and Data Driven framework concepts. The sample driver script above opens the Keyword file, then reads each of the rows in the file. In each row, it reads the Action statement, then calls the appropriate function. The arguments of the function are based on other fields in that row.


Keyword Driven Pros

* Increased Reusability – Reusability is even further increased with a Keyword Driven framework, because most of the functions are created in such a way to not only be reusable for multiple tests within a single application, but also for tests across multiple applications. Redundancy may therefore be decreased across all applications that an organization may be responsible for automating.
* Earlier script development – This framework increases the ability for automation to begin before the application is delivered. Using information gathered from Requirements or other documentation, keyword data tables can be created that mirror corresponding manual test procedures.
* The script is easier to read – Keyword data tables are often easier to read than regular test scripts, because the keyword data tables mirror manual test procedures. The keywords are typically verb-like phrases that make reading a keyword data table similar to reading a collection of sentences, which is easier than reading code statements that don’t mirror natural language.
* Increased standardization – The increase of reusable framework components is followed by increased standardization. The added advantage that the Keyword Framework has over Functional Decomposition, however, is that standards are by default imposed through the implementation of a Keyword framework. Provided that the framework components are created with appropriate standards, they will be invoked in the keyword data tables with every use of the framework’s keywords. Standardization helps with script maintenance, because it decreases guess work involved in figuring out what a script does and how best to fix it.
* Error handling easier to introduce – Patch work error handling solutions on a script by script basis are difficult to introduce and maintain. With reusable Keyword framework components, error handling can be introduced that reaches multiple scripts across multiple applications. This will ultimately improve the effectiveness of unattended execution of the test scripts.
* Decreases technical nature of application automation – Working with keyword data tables for everyday application automation is a lot less technical than working with code statements. Therefore individuals that are not as technical can be brought onto the team to help create automated tests.
* Greater traceability to manual test cases – Given the fact that keyword data tables so closely resemble a manual test procedure, it becomes simpler to trace actions in automated tests to actions in manual tests. In addition, there will be greater reuse of manual test procedures.


Keyword Driven Challenges (Cons)

* Required technical expertise – While the technical nature of creating automated tests within the framework is decreased, the technical skills required to create and maintain the framework itself is greatly increased from that required for Functional Decomposition frameworks. There are numerous dependencies and relationships that must be understood and maintained, as well as advanced tool components and structures.
* Intuition is less useful – In order to effectively implement a Keyword framework, reliance on intuition must be reduced, while reliance on standards must be increased. While some standards are automatically imposed, with this type of framework, many standards are not, so there’s an ongoing effort to ensure resources are aware of standards, understand them, and are able to effectively implement them. Increased documentation will probably be required to identify framework features, particularly documentation that chronicles the keywords that exist as part of the framework that may be used.
* Increased management support – Management support is a challenge for any automation effort, but it is particularly difficult with Keyword Driven frameworks. There must be strong management support, however, for the time and resources necessary for creating and maintaining the structures, documentation, and personnel (both technical and non-technical).
* Restrictive for technical staff – For technically adept resources that are tasked with day-to-day automation of a software application, Keyword frameworks may be overly restrictive. They may be perceived as an entity that “ties their hands” into automating in a “standard” way at the expense of automating in the most efficient way for a particular application, or particular feature within an application. Keyword applications typically require increased “public relations” work to sale the approach to both resources and management.

2nd Generation Frameworks: DATA DRIVEN

This is the middle ground for test automation frameworks, and may be simple, or really well defined. This framework should be considered whenever maintenance is a factor. It is important to have a strong understanding of this generation, since third-generation frameworks are also based on second-generation concepts. The two frameworks that fit into this generation are the Data-driven framework and Functional Decomposition framework.

Most Second Generation frameworks are a hybrid of both Data-driven and Functional Decomposition, but it is possible to have one without the other, so they will be discussed independently.

Functional Decomposition PDF Print E-mail

Functional Decomposition refers broadly to the process of producing modular components (user-defined functions) in such a way that automated test scripts can be constructed to achieve a testing objective largely by combining these existing components.





The modular components are often created to correspond with application functionality, but there are a lot of different types of user-defined functions that may be created. These function types may include the following:

* Utility functions – These are functions that represent fundamental framework actions or the basic functionality of a specific application under test. For example, a function that is responsible for logging into the application would be considered a utility function. These functions can be identified from the requirements or from the manual test cases, related to the groups of tests that are slated for automation.
* Navigation functions – Most applications have several main areas that are navigated to many times during testing. The paths are basic paths that can often very easily be identified at the very beginning of the automation process.
* Error handling functions – Error handling functions are functions created to deal with certain unexpected events that may occur during testing.
* Miscellaneous functions – These are functions that don’t fall under any of the other categories.

The Functional Decomposition framework may vary from having a relatively low level of complexity to high level of complexity, based on the level at which functions are created. Functions may be created for simple tasks such as menu clicks, or may be created for complex functional activities, complex error handling routines, and complex reporting mechanisms.


Functional Decomposition Script Pros

* Increased Reusability – Reusability is greatly increased with the introduction of functional decomposition, because reusable functions may be created and made available for use by multiple tests. Redundancy may be decreased for all tests within a given application, and may also be reduced across multiple applications, depending on the level of abstraction at which the function is created. With increased reusability maintainability is greatly increased.
* Script Independence – Although the Functional Decomposition Framework may use multiple external components, the tests themselves are not being reused. This allows for the introduction of reusability while still maintaining script independence.
* Earlier script development – Functional decomposition makes it possible to in some instances begin developing automated tests even before the application is delivered. Using information gathered from Requirements or other documentation, placeholder components can be created and used for developing automated tests in a top-down development approach. Once the application becomes available the components can be appropriately updated.
* The script is easier to read – Automated tests are easier to maintain when broken into small components because it is simpler to visually determine what the script is trying to accomplish.
* Increased standardization – With the increase of reusable framework components comes increased standardization. Standardization aids in script development, because it decreases much of the guess work involved in creating scripts. In addition, standardization helps with script maintenance, because it decreases guess work involved in figuring out what a script does and how best to fix it.
* Error handling is easier to introduce – Patch work error handling solutions on a script by script basis are difficult to introduce and maintain. With reusable components, error handling that reaches multiple scripts can be introduced. This will ultimately improve the effectiveness of unattended execution of the test scripts.


Functional Decomposition Script Challenges (Cons)

* Required technical expertise – As an automated test framework begins to utilize more technical solutions, that framework, by default, begs for more technically adept resources to design, develop and maintain it. This concept holds true for the functional decomposition framework.
* Intuition is less useful – In order to effectively implement an advanced framework, reliance on intuition must be reduced, while reliance on standards must be increased. While standardization is a positive by product of Functional Decomposition, it also poses a challenge in ensuring resources are aware of standards, understand them, and are able to effectively implement them. Increased documentation will probably be required to identify framework features, particularly documentation that chronicles the functions that exist as part of the framework.
* Maintenance becomes more complex – As the complexity of the framework increases, so does the amount of maintenance that is required. With Linear scripts, maintenance is confined solely to a script that breaks. While, this may result in excess maintenance for Linear scripts (because a single application change can make multiple scripts susceptible to failures), it also helps make maintenance a little less complex. With Functional Decomposition, maintenance is often required for both the framework and specific scripts. While this may reduce the amount of maintenance required, it also makes maintenance a little more complex.

Data-driven PDF Print E-mail

Frameworks built on Data-driven scripting are similar to Linear scripts, in that most of the components that are executed by a Data-driven script largely exist within the body of that script. The difference is seen in how the data is handled. The data used in Data-driven scripts is typically stored in a file that is external to the script. By parameterizing application input fields and associating the external data to its respective parameter, the run-time data will no longer be hard-coded in the script, but rather obtained from the external file. For example, below is a linear script example.


1 Input “John” into Username textbox
2 Input “JPass” into Password textbox
3 Click Login button
4 If “Welcome Screen” exists then
5 Pass the test
6 Else
7 Fail the test
8 End If



A Data-driven version of this script would store the data in an external data file (spreadsheet, database, xml file, etc.), as shown below.



NameParameter


PasswordParameter
John JPass
Sue SPass
Randy RPass
Trina TPass



The data-driven version of the Linear script shown above, may appear as follows:


1 Open Data Table
2 Input into Username textbox
3 Input into Password textbox
4 Click Login button
5 If “Welcome Screen” exists then
6 Pass the test
7 Else
8 Fail the test
9 End If
10 Close Data Table



Notice the data (John, JPass) has been removed from the script, and replaced with data table parameters.

This approach allows for the same blocks of code to be used for different data. Data-driven automation is often considered a technique as opposed to a framework, and when used as a technique, you may have several data-driven constructs within a single test script. Using the Data-driven approach as a framework does little to address many of the challenges that exist in Linear scripts, but reusability is introduced and is useful under certain circumstances.
Data-driven Script Pros

* Reusability – Data-driven scripts offer a relatively simple way to introduce reusability to automated tests. The same block of code can be reused with different data, making it possible for many test cases to be executed with minimal scripting.
* Simple to implement – It’s simple in that it requires minimal updates to existing scripts. It often involves creating parameters in place of hard coded values and placing looping structures around your code.


Data-driven Script Challenges (Cons)

* Redundancy – While Data-driven scripts allow for some degree of reusability, there is still a large degree of redundancy across multiple scripts that perform similar actions. As with Linear scripts, functionality may be duplicated in each respective script, making the scripts susceptible to excessive maintenance.
* One dimensional scripts – Little flexibility is offered in altering the way Data-driven scripts may be executed. Scripts are only readily available to be run at one level, in one location and in one way. If a test manager wants the automator to execute a subset of the total test bed based on defined priorities and risks, or execute the tests in a different environment, or in a different sequence, the automator would have to perform time consuming, run-time analysis of the scripts to make it happen. This will decrease the amount of time available for script execution and analysis.
* Script is difficult to read – With the absence of reusable components, Data-driven scripts are replete with code or automation statements. This will make the script difficult to read and therefore tedious to analyze and maintain. If a statement in the script fails, it is often difficult to determine what application functionality was affected by failure. Likewise, when it becomes necessary to make changes to the script, it is a little more tedious to determine where the changes need to be made.
* Requires higher degree of application knowledge – In order to maintain Data-driven scripts, a higher degree of application knowledge is required. This is directly related to the fact that there is little modularity. Modularity helps to make it clear what a block of application statements is responsible for doing. The loose statements in Linear Scripts make it a little less clear. So when it comes to analyzing and/or debugging a script the automator must first burn a substantial amount of time gaining a mental understanding of what a given block of statements does in order to effectively maintain the script.

1st Generation Frameworks LINEAR

1st Generation Frameworks
Framework.jpg The first generation of test automation is primarily comprised of the Linear approach to automated test development. The Linear approach typically yields a one-dimensional set of automated tests in which each automated test is treated simply as an extension of its manual counterpart. Driven mostly by the use of the Record & Playback, all components that are executed by a Linear script largely exist within the body of that script. There is little to no modularity, reusability, or any other Quality Attribute considered in the creation of Linear scripts. Linear Scripts, may be useful in environments with a very small scope.
Linear
The Linear "framework" typically yields a one-dimensional set of automated tests in which each automated test is treated simply as an extension of its manual counterpart. Driven mostly by the use of the Record & Playback, all components that are executed by a Linear script largely exist within the body of that script. There is little to no modularity, reusability, or any other Quality Attribute considered in the creation of Linear scripts. Linear Scripts, may be useful in environments with a very small scope. An example of a small linear script is shown below.
1 Input “John” into Username textbox
2 Input “JPass” into Password textbox
3 Click Login button
4 If “Welcome Screen” exists then
5 Pass the test
6 Else
7 Fail the test
8 End If

Notice that there are not calls to external modules, or external data.

Linear scripts are often driven by Record & Playback should, but in most cases, Record & Playback should not be treated as a framework or serious approach for an automation effort meant to span any real length of time. Some will agree, however, that while Record and Playback is not good as a framework, it may be useful as a technique.

Linear Script Pros
* Quick development – There is little planning or consideration of the various Quality Attributes when creating Linear scripts. Couple this information with the fact that Record and Playback is often the driving force behind Linear script development, then it’s easy to see that cost of development in time, resources and money could be relatively low.
* Smaller tool learning curve – Test automation typically requires knowledge of the automation tool features and language, as well as the knowledge of how the tool interacts with the application under test. The use of Record and Playback in the creation of Linear scripts dynamically creates code that corresponds with actions performed in the application. This code may then be studied by the automator for answers to questions about the tool’s language syntax as well as how the automated test tool’s interaction with the AUT.
* Quickly gather information about application dynamics – This advantage is closely related to the smaller tool learning curve advantage. The use of Record and Playback provides information about the Aut dynamics, such as how object properties change as activity in the application is altered.
* Script Independence – Given the fact that all the components executed by a script exist within that script, there is little apprehension about making script modifications that may unknowingly affect some other script.
* Simplifies error location – The more advanced an automation framework becomes the more complex it becomes. With complexity comes challenges related to locating the source of an error, particularly for those that are unfamiliar with the makeup of the automation framework. Given the fact that all components of a Linear script exist within that script, there is little question about where the error occurred.

Linear Script Challenges (Cons)

* Improper playback – When relying heavily on Record and Playback, recorded scripts will often not playback properly. This is due to the fact that the Record and Playback feature is not analytical. It doesn’t evaluate the application objects and behavior nor does it make decisions on how best to deal with those objects and behaviors. In an effort to fix the playback issues, a series of patchwork solutions are often introduced that won’t stand the test of time.
* Redundancy – Linear scripts don’t take advantage of reuse, therefore if more than one script performs the same or similar functionality, the functionality will be duplicated in each respective script. When the application changes in subsequent releases of the application, excessive maintenance will be the result.
* One dimensional scripts – Little flexibility is offered in altering the way Linear scripts may be executed. Scripts are only readily available to be run at one level, in one location and in one way. If a test manager wants the automator to execute a subset of the total test bed based on defined priorities and risks, or execute the tests in a different environment, or in a different sequence, the automator would have to perform time consuming, run-time analysis of the scripts to make it happen. This will decrease the amount of time available for script execution and analysis.
* Scripts are difficult to read – With the absence of reusable components, Linear scripts are replete with code or automation statements. This will make the script difficult to read and therefore tedious to analyze and maintain. If a statement in the script fails, it is often difficult to determine what application functionality was affected by failure. Likewise, when it becomes necessary to make changes to the script, it is a little more tedious to determine where the changes need to be made.
* Requires higher degree of application knowledge – In order to maintain Linear scripts, a higher degree of application knowledge is required. This is directly related to the fact that there is little modularity. Modularity helps to make it clear what a block of application statements is responsible for doing. The loose statements in Linear Scripts make it a little less clear. So when it comes to analyzing and/or debugging a script the automator must first burn a substantial amount of time gaining a mental understanding of what a given block of statements does in order to effectively maintain the script.

Wednesday, November 11, 2009

Preparing for CSTE testing certification exam

1. Verification is:
a. Checking that we are building the right system
b. Checking that we are building the system right
c. Performed by an independent test team
d. Making sure that it is what the user really wants

2. A regression test:
a. Will always be automated
b. Will help ensure unchanged areas of the software have not been affected
c. Will help ensure changed areas of the software have not been affected
d. Can only be run during user acceptance testing

3. If an expected result is not specified then:
a. We cannot run the test
b. It may be difficult to repeat the test
c. It may be difficult to determine if the test has passed or failed
d. We cannot automate the user inputs

4. Which of the following could be a reason for a failure
1) Testing fault
2) Software fault
3) Design fault
4) Environment Fault
5) Documentation Fault
a. 2 is a valid reason; 1,3,4 & 5 are not
b. 1,2,3,4 are valid reasons; 5 is not
c. 1,2,3 are valid reasons; 4 & 5 are not
d. All of them are valid reasons for failure

5. Test are prioritized so that:
a. You shorten the time required for testing
b. You do the best testing in the time available
c. You do more effective testing
d. You find more faults

6. Which of the following is not a static testing technique
a. Error guessing
b. Walkthrough
c. Data flow analysis
d. Inspections

7. Which of the following statements about component testing is not true?
a. Component testing should be performed by development
b. Component testing is also know as isolation or module testing
c. Component testing should have completion criteria planned
d. Component testing does not involve regression testing

8. During which test activity could faults be found most cost effectively?
a. Execution
b. Design
c. Planning
d. Check Exit criteria completion

9. Which, in general, is the least required skill of a good tester?
a. Being diplomatic
b. Able to write software
c. Having good attention to detail
d. Able to be relied on

10. The purpose of requirement phase is
a. To freeze requirements
b. To understand user needs
c. To define the scope of testing
d. All of the above

11. The process starting with the terminal modules is called -
a. Top-down integration
b. Bottom-up integration
c. None of the above
d. Module integration

12. The inputs for developing a test plan are taken from
a. Project plan
b. Business plan
c. Support plan
d. None of the above

13. Function/Test matrix is a type of
a. Interim Test report
b. Final test report
c. Project status report
d. Management report

14. Defect Management process does not include
a. Defect prevention
b. Deliverable base-lining
c. Management reporting
d. None of the above

15. What is the difference between testing software developed by contractor outside your country, versus testing software developed by a contractor within your country?
a. Does not meet people needs
b. Cultural difference
c. Loss of control over reallocation of resources
d. Relinquishments of control

16. Software testing accounts to what percent of software development costs?
a. 10-20
b. 40-50
c. 70-80
d. 5-10

17. A reliable system will be one that:
a. Is unlikely to be completed on schedule
b. Is unlikely to cause a failure
c. Is likely to be fault-free
d. Is likely to be liked by the users

18. How much testing is enough
a. This question is impossible to answer
b. The answer depends on the risks for your industry, contract and special requirements
c. The answer depends on the maturity of your developers
d. The answer should be standardized for the software development industry

19. Which of the following is not a characteristic for Testability?
a. Operability
b. Observability
c. Simplicity
d. Robustness

20. Cyclomatic Complexity method comes under which testing method.
a. White box
b. Black box
c. Green box
d. Yellow box

21. Which of these can be successfully tested using Loop Testing methodology?
a. Simple Loops
b. Nested Loops
c. Concatenated Loops
d. All of the above

22. To test a function, the programmer has to write a ______, which calls the function and passes it test data.
a. Stub
b. Driver
c. Proxy
d. None of the above

23. Equivalence partitioning is:
a. A black box testing technique used only by developers
b. A black box testing technique than can only be used during system testing
c. A black box testing technique appropriate to all levels of testing
d. A white box testing technique appropriate for component testing

24. When a new testing tool is purchased, it should be used first by:
a. A small team to establish the best way to use the tool
b. Everyone who may eventually have some use for the tool
c. The independent testing team
d. The vendor contractor to write the initial scripts

25. Inspections can find all the following except
a. Variables not defined in the code
b. Spelling and grammar faults in the documents
c. Requirements that have been omitted from the design documents
d. How much of the code has been covered

Friday, August 7, 2009

Why Automate?

A prevalent belief among IT folk is that automation, by default, will enhance the quality of testing.

How true is that belief?

“There is a time and place for everything”, as the popular idiom goes, and that holds true for test automation too.

Certain scenarios in which automation is generally a good option:
1. Repetitive Tests

A system that needs the same tests executed periodically is a good candidate for automation. Take for example, support projects that must perform regression tests for every PR/CR. Manual effort in such cases tends to be huge and error-prone. Automation can prove very efficient in such cases.

It makes sense to opt for a testing tool with a version controlled repository to manage the test scripts.

The cost of automation and the initial effort investment for script creation is usually greater than for manual testing, and it must be analyzed how far this investment will pay off in the end. A few pointers to help make that decision:

* How many repetitions of tests are expected, for how long? A longer “life” of the test scripts tips the scale in favor of automation.
* How expensive is the tool?
* How much time/effort will it take to create the test scripts? Automation may not simply be record-and-play, a lot of design and coding may have to go in to achieve the desired result.
* Are incremental changes expected to the scripts?
* Do testers on the team require training on the tool?

“Repetitive tests => automation” is a fair thumb rule but not an inviolable one. A costly automation setup on one hand and quick-to-build on-the-fly manual tests on the other, and you might just find that automation will not be useful even if you expect a certain number of repetitions.
2. Manually Infeasible Tests

Before an application is deployed in the production environment, it might be critical to determine how the application will behave under huge user load or when dealing with millions of records.

Such test scenarios are usually best simulated with automation. In high risk conditions, where the cost of missing a test might be disastrous, even a single-time use of automation might be a worthwhile decision.
3. Low Severity/Probability Of “Human” Bugs

Automation can perform some jobs far better than a human can hope to do. Give the tool and the human tester two excel sheets with 10,000 rows of data each to reconcile with each other. No prizes for guessing who can do it faster, without errors.

But then, humans are far better at another sort of testing. Humans can notice oddities beyond documented tests. Does the UI look too cluttered? Does the mouse flicker strangely when moved over the button? Did the screen behind the modal window just blink?

Automation is limited to testing what it is programmed to do. Not everything that the human mind can observe/analyze can be programmed, and so, automation will miss out on capturing some bugs. The question to ask is: how important are those missed-out bugs? An unstable system might not be ready for automation, as severe “manual” bugs may get ignored. Automation is better suited to systems in which the “human” bugs are expected to be fewer and are of low severity.

In Closing

A point worth remembering is that automation vs. manual does not have to be an either-or decision. A mix can work. Take a multi-step workflow – a couple of steps might be fit for automation, not the entire flow. Automate only those steps that will benefit from automation.

Tuesday, August 4, 2009

VBScript Operators:

VBScript Operators

Arithmetic Operators:Operators used to perform mathematical calculations.

1. Addition +
2. Subtraction -
3. Multiplication *
4. Division /
5. Integer Division \
6. Exponentiation ^
7. Modulus arithmetic Mod
8. Unary negation -
9. String concatenation &

Assignment Operator:Operator used to assign a value to a property or variable.

1. Equality =
2. Inequality <>
3. Less than <
4. Greater than >
5. Less than or equal to <=
6. Greater than or equal to >=

Comparison Operators:Operators used to perform comparisons.

Concatenation Operators:Operators used to combine strings.

Logical Operators:Operators used to perform logical operations.

1. Logical negation Not
2. Logical conjunction And
3. Logical disjunction Or
4. Logical exclusion Xor
5. Logical equivalence Eqv
6. Logical implication Imp

Using Control Structures to Make Decisions:

Using If...Then...Else
Syntax
If condition Then statements [Else elsestatements ]
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements] ...
[Else
[elsestatements]]
End If
Ex:
If condition = True Then
... the code that executes if the condition is satisfied
End If
Ex:
If bShowDetail Then MsgBox "More details. . . "
example:
sMsg = "Either you're not born yet or you're getting too old for this stuff!"
If nAge <= 0 Or nAge > 120 Then
MsgBox sMsg
bFail = True
End If
Ex:
If MyFavoriteRestaurantOpen = True Then
Msgbox "Go To My Favorite Restaurant!"
End If
If MyFavoriteRestaurantOpen = False Then
Msgbox "Go Home and Cook!"
End If
Ex:
If MyFavoriteRestaurantOpen = True Then
Msgbox "Go To My Favorite Restaurant!"
Else
Msgbox "Go Home and Cook!"
End If
Ex:
If nAge = 0 Then
MsgBox "Welcome to the human race!"
ElseIf nAge < 0 Then
MsgBox "You have to grow up a bit before you start using VBScript!"
ElseIf nAge > 0 And Age < 10 Then
MsgBox "If you're bold enough, you must be old enough."
ElseIf nAge > 120 Then
MsgBox "You're getting too old for this stuff!"
Else
MsgBox "You're at the perfect age to get started!"
End If

Allows for conditional execution of a block of code, typically out of three or
more code blocks, based on some condition. Use the Select Case statement as
an alternative to complex nested If...Then...Else statements.
Select Case
Syntax
Select Case testexpression
[Case expressionlist-n
[statements-n]] ...
[Case Else
[elsestatements]]
End Select

A Select Case statement provides capability similar to the If...Then...Else
statement, but it makes code more efficient and readable. Select Case
structure is defined as follows:
Select Case expression
Case exp-1
...this is the code that executes if exp-1 matches expression
Case exp-2, exp-3
...this is the code that executes if exp-2 or exp-3 matches expression
Case exp-4
...this is the code that executes if exp-4 matches expression
.
.
.
Case Else
...this is the code that executes if none matches expression
End Select
Example
The following example uses Select Case to read a variable populated by the
user and determine the name of the user's operating system:
Select Case Left(Environment.Value("OSVersion"), 1)
Case 1 : varOSDesc = "Windows NT"
Case 2 : varOSDesc = "Windows 98"
Case 3 : varOSDesc = "Windows 95"
Case 4 : varOSDesc = "Windows 3.11"
Case 5 : varOSDesc = "Windows 2000"
Case 6 : varOSDesc = "Windows ME"
Case 7 : varOSDesc = "Windows XP"
Case Else : varOSDesc = "OS is unknown"
End Select
Using Control Structures to Make Code Repeat:

Looping allows you to run a group of statements repeatedly. Some loops repeat statements until a condition is False; others repeat statements until a condition is True. There are also loops that repeat statements a specific number of times.
The following looping statements are available in VBScript:
Do...Loop: Loops while or until a condition is True.
While...Wend: Loops while a condition is True.
For...Next: Uses a counter to run statements a specified number of times.
For Each...Next: Repeats a group of statements for each item in a collection or
each element of an array.

Using For...Next Statement:
Defines a loop that executes a given number of times, as determined by a loop counter. To use the For...Next loop, you must assign a numeric value to a counter variable. This counter is either incremented or decremented automatically with each iteration of the loop. In the For statement, you specify the value that is to be assigned to the counter initially and the maximum value the counter will reach for the block of code to be executed. The Next statement marks the end of the block of code that is to execute repeatedly, and also serves as a kind of flag that indicates the counter variable is to be modified.
Syntax
For counter = start To end [Step stepcounter]
[statements]
[Exit For]
[statements]
Next

Arguments
Argument Description
counter
Numeric variable used as a loop counter. The variable can't be an array
element or an element of a user-defined type.
start Initial value of counter.
end Final value of counter.
step
Amount counter is changed each time through the loop. If not specified, step defaults to one.
statements
One or more statements between For and Next that are executed the specified number of times.

Using If...Then...Else
Syntax
If condition Then statements [Else elsestatements ]
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements] ...
[Else
[elsestatements]]
End If
Ex:
If condition = True Then
... the code that executes if the condition is satisfied
End If
Ex:
If bShowDetail Then MsgBox "More details. . . "
example:
sMsg = "Either you're not born yet or you're getting too old for this stuff!"
If nAge <= 0 Or nAge > 120 Then
MsgBox sMsg
bFail = True
End If
Ex:
If MyFavoriteRestaurantOpen = True Then
Msgbox "Go To My Favorite Restaurant!"
End If
If MyFavoriteRestaurantOpen = False Then
Msgbox "Go Home and Cook!"
End If
Ex:
If MyFavoriteRestaurantOpen = True Then
Msgbox "Go To My Favorite Restaurant!"
Else
Msgbox "Go Home and Cook!"
End If
Ex:
If nAge = 0 Then
MsgBox "Welcome to the human race!"
ElseIf nAge < 0 Then
MsgBox "You have to grow up a bit before you start using VBScript!"
ElseIf nAge > 0 And Age < 10 Then
MsgBox "If you're bold enough, you must be old enough."
ElseIf nAge > 120 Then
MsgBox "You're getting too old for this stuff!"
Else
MsgBox "You're at the perfect age to get started!"
End If

Allows for conditional execution of a block of code, typically out of three or
more code blocks, based on some condition. Use the Select Case statement as
an alternative to complex nested If...Then...Else statements.
Select Case
Syntax
Select Case testexpression
[Case expressionlist-n
[statements-n]] ...
[Case Else
[elsestatements]]
End Select

A Select Case statement provides capability similar to the If...Then...Else
statement, but it makes code more efficient and readable. Select Case
structure is defined as follows:
Select Case expression
Case exp-1
...this is the code that executes if exp-1 matches expression
Case exp-2, exp-3
...this is the code that executes if exp-2 or exp-3 matches expression
Case exp-4
...this is the code that executes if exp-4 matches expression
.
.
.
Case Else
...this is the code that executes if none matches expression
End Select
Example
The following example uses Select Case to read a variable populated by the
user and determine the name of the user's operating system:
Select Case Left(Environment.Value("OSVersion"), 1)
Case 1 : varOSDesc = "Windows NT"
Case 2 : varOSDesc = "Windows 98"
Case 3 : varOSDesc = "Windows 95"
Case 4 : varOSDesc = "Windows 3.11"
Case 5 : varOSDesc = "Windows 2000"
Case 6 : varOSDesc = "Windows ME"
Case 7 : varOSDesc = "Windows XP"
Case Else : varOSDesc = "OS is unknown"
End Select
Using Control Structures to Make Code Repeat:

Looping allows you to run a group of statements repeatedly. Some loops repeat statements until a condition is False; others repeat statements until a condition is True. There are also loops that repeat statements a specific number of times.
The following looping statements are available in VBScript:
Do...Loop: Loops while or until a condition is True.
While...Wend: Loops while a condition is True.
For...Next: Uses a counter to run statements a specified number of times.
For Each...Next: Repeats a group of statements for each item in a collection or
each element of an array.

Using For...Next Statement:
Defines a loop that executes a given number of times, as determined by a loop counter. To use the For...Next loop, you must assign a numeric value to a counter variable. This counter is either incremented or decremented automatically with each iteration of the loop. In the For statement, you specify the value that is to be assigned to the counter initially and the maximum value the counter will reach for the block of code to be executed. The Next statement marks the end of the block of code that is to execute repeatedly, and also serves as a kind of flag that indicates the counter variable is to be modified.
Syntax
For counter = start To end [Step stepcounter]
[statements]
[Exit For]
[statements]
Next

Arguments
Argument Description counter
Numeric variable used as a loop counter. The variable can't be an array element or an element of a user-defined type.
start Initial value of counter.
end Final value of counter.
step
Amount counter is changed each time through the loop. If not specified, step defaults to one.
statements
One or more statements between For and Next that are executed the specified number of times.

Tuesday, April 7, 2009

Features of QTP:

  • Ease of use.
  • Simple interface.
  • Presents the test case as a business workflow to the tester (simpler to understand).
  • Uses a real programming language (Microsoft’s VBScript) with numerous resources available.
  • QuickTest Pro is significantly easier for a non-technical person to adapt to and create working test cases, compared to WinRunner.
  • Data table integration better and easier to use than WinRunner.
  • Test Run Iterations/Data driving a test is easier and better implement with QuickTest.
  • Parameterization easier than WinRunner.
  • Can enhance existing QuickTest scripts without the “Application Under Test” being available; by using the ActiveScreen.
  • Can create and implement the Microsoft Object Model (Outlook objects, ADO objects, FileSystem objects, supports DOM, WSH, etc.).
  • Better object identification mechanism.
  • Numerous existing functions available for implementation - both from within QuickTest Pro and VBScript.
  • QTP supports .NET development environment
  • XML support
  • The Test Report is more robust in QuickTest compared to WinRunner.
  • Integrates with TestDirector and WinRunner (can kick off WinRunner scripts from QuickTest).

Thursday, April 2, 2009

Released of Quicktest Profesisonal 10, Quality Center 10 and LoadRunner 9.5.

HP has held a conference (30/3) regarding the release of Quicktest Profesisonal 10, Quality Center 10 and LoadRunner 9.5. While the presentations did not present a detailed account of the products (due to severe time constraints):

The tweets are presented from first to last (reversed from the usual twitter display): At HP’s BTO conference.
Starting with Uri Bergman’s introduction
@GlennHalstead Yeah, Ayal Cohen will present QTP 10, Elad Shulman will present QC. Alon Linetzki will also give a lecture.
Giving a general overview of HP software services, and HP software @ Israel
Yuval Riess giving a general overview of HP’s BTO approach.
An original way for presenting BTO services.
Elad Shulman now presenting QC 10.
Elad presents Baseline - A very cool version-freeze ability for all QC entities.
Check-in / Check-out is pretty well implemented in QC
Now in Beta - importing VS / Clearcase entities to QC - Completely replaces the integrations to external tools
New central authority for defining and publishing policy and template updates.
The old QC dashboard is now the standard reporting module.
Though there is no longer the ability to write crazy free SQLs for reportss.
Some of the old Dashboard reports won’t import well to QC 10! HP will offer per-case support for the migration.
Test resources are now REALLY managed (you can see and manage callback and "who uses" for every resource).
QC upgrade will be greatly improved, both in compatibility, and in change traceability.
New version of QC synchronizer for quickly developing custom integrations for QC.
Elad finishing the Q&A session. Next, Ayal Cohen on QTP. http://twitpic.com/2ll3r
Ayal will give a hardcore presentation - most of it will be live demonstration.
QTP will make use of QC resource management. This will prevent us from stupidly deleting a valuable function / Excel sheet.
Excellent resource viewers to look at object repositories, excel and function libraries straight from QC.
Ayal dramatically presents the amazing Version compare of QTP versions.
You can compare everything from code, test-settings, external resources, and MUCH more.
The detailed script-compare mechanism brings the best of the best programmers text-compare tools.
Don’t miss AdvancedQTP full review of QTP 10:
Running through the new Local System Monitor feature. The report resource graphs are excellent.
Showing the new report graphs.
Ayal is rushing through the reporter improvements. No time left, and it’s a shame as these are really cool features.
Going through the new IDE improvements. Sadly, there’s no time for a detailed walkthrough.
The rushed presentation doesn’t do justice to the new IDE features. Read about them in our review:
At least the "Save with resources" got the attention it deserve. You can very easily pack a test with all its resources for relocation.
The crowed awes at the dynamic "LoadAndRunAction", which allows to call actions without pre-associating them.
Ayal finishes his presentation. If only he had 15 more minutes.
Ayal gives an important Q
Out for a coffee break.
As a general note - all the presentations are very well constructed from a technical, visual and a delivery standpoint
Staring the LoadRunner session
LR session http://twitpic.com/2lm0x
As a general theme - LR will open much more APIs, both for reporting and for the actual controller.
New protocol Advisor - LR monitors the business process, and generates a list of relevant add-ins and protocols for the AUT
LR 9.5 renews the partnership with Shunra for simulating WAN conditions of different virtual users
Extracting run-data from the LR run-session database is not extremely easy via the API. Also, there’s a fast result exporting engine.
The ability to perform cross result session comparisons is enhanced with a summery view which highlights the meaningful differences.
Finally! A new secure channel for encrypting and validating the communications between the controller and generation.
LR 9.5 adds support for RTMP. It’s an old protocol, but now that Flex have adopted it, HP have added support for RTMP on TCP.
YES! LR can now reference custom Serialize / Deserialize functions. This allows LR to decrypt encrypted / compressed communications.
Some improvements to Click-And-Script, both in coverage (DOM mostly), and in performance. Nothing too exciting.
New in recording Remote Desktop communication. If you could install a small component on the server side, LR will produce dramatically m …
Also, you can now adjust the tolerance of RDP / Citrix image comparisons.
Reviewing the new supported environments. All the usual suspects, nothing worth mentioning.
Now sidetracking for a minute to "Performance Center". For LR analysis and dashboarding.
The new performance center now includes a new Trends view that compares run results either to the past, or to a baseline.
Demonstrating Performance Center reports.
I didn’t work with Performance Center, but all the new features are pretty much what I would’ve expected in version 1.0.
The LR session has Ended. Next - a presenter from Elbit presents a client story on using HP tools.
Yevgeni presenting on behalf of Elbit Systems.
Elbit is a multi-tool company. Uses QTP, QC, IBM RTF, Compuware DevPartner, IBM Purify, Enterprise Architect, VSTS, ClearCase, VSS, and …
Computer out of power. Use iPhone to tweet.
Only now moving to something remotely relevant. Talking about the project lifecycle and the constraints on automation and CM.
This presentation really highlights how good were the HP presentations. This is just death by powerpoint.
How not to build a slide. NM The actual text, it’s just an endless flat list.
It’s over! Next up, Alon Linetzki - ITCB vice president.
Alon wil discuss testing certification details and impact.
The ISTQB global organization for testing certificate now operates in over 40 countries.
Claims you cannot get a job as a tester in the UK without ISTQB certification. Can anyone comment on this?
It seems that soon many companies will make the certification mandatory for new recruits.
Makes an interesting point: there are dozens of conflicting definitions for test-case, STP, etc. ISTQB sets to put an end to all that.
Closing word on the importance of certification. Personally, as for HP certification - it’s worthless.
Well, that all, the event has ended. Thanks for following it, and make sure to visit AdvancedQTP for all your QTP needs.

QTPINTERVIEQUATIONS

1. What is Test Frame Work?
2. How comfortable are you in VB Scripting?
3. What is Description Object?
4. What are SetToProperty, SetRoProperty, GetToProperty scripting?
5. What is the difference between version 6.5 and 8.2?
6. What is the difference between Normal mode and Fast mode?
7. How do you invoke the application through QTP?
8. How do you close the Task Manager through QTP?
9. How will you load the object during run time?
10. How will you handle the situation when object is not captured during record?
11. What is test object?
12. How QTP recognizes the objects stored in object repository
13. What is post recovery scenario?
14. What is reusable action and how the same can be implemented (process)
15. How will u integrate oracle with QTP
16. How QTP integrate with application
17. What is object repository?
18. What are all the fields present in object repository?
19. What is smart identification?
20. What are the mandatory properties for a text box (scenario?)
21. What is Checkpoint?
22. What is object?
23. What are the properties of object?
24. What is Action?
25. What will be there in Keyword view and Expert View?
26. What is regular expression how will u implement it
27. Where the checkpoints are stored
28. What is database checkpoint, how will u parameterize the database from separate data table
29. How will u handle application crash using recovery scenario manager (Step By Step Process)
30. What is Virtual Object?
31. What is the difference between calling a function and reusing an action?
32. How QTP support all types of applications (Platforms)
33. What is the difference between application testing and product testing?
34. What is throw object?
35. What is Run-time Data?
36. How will you enhance the script?
37. Can objects recognised without repository?
38. Where did u automate in ur project
39. Any challenge that faced in ur project
40. Batch test, run action
41. Purpose of automation
42. Diff ways of parameter sing
43. Error handled other than recovery scenario manager
44. Diff betw WR and QTP
45. What kind of errors can b handled?
46. How you used DDT in QTP?
47. Difference between keyword driven test and DDT?
48. How did you use regular expression in QTP and also in Win Runner?
49. How do you learn the object in QTP?
50. How will you handle custom object in QTP?
51. Differences in QTP and Win Runner.
52. Give us the Definition for Integration Testing, Regression Testing System Testing
53. How will you report the bug and explain the defect tracking Sheet you handled?
54. What In-string function will do?
55. What is L-trim function will do?
56. Win Runner and QTP difference?
57. In website, protocol has been changed http: to https what you will do? Tell me you’re Approach?
58. What Framework you are following?
59. How to load the object repository at run time?
60. How much strong on VB and C?
61. How to compare the 2 strings?
62. What is the Silent mode in Win Runner?
63. Have you worked with Quality Canter?
64. Have you used Test Director?
65. What is QTP Test Frame work?
66. Definitions for Keyword view and Tree View?
67. What is Smart Identification?
68. What is Object Repository?
69. What is your experience level in QTP?
70. What is your Role and Responsibilities in QTP with your current organisation?
71. Import and Export of files.
72. Random testing of 500 test cases.
73. Invoking of application
74. Opening notepad in QTP &Writing of Test Result in Notepad.
75. Merging of Two Repositories
76. Data file / Verification of data file when file is not available in local system.
77. Business process component / Types and usage.
78. Opening of notepad in QTP to write and execute the coding.
79. How to find local host name using QTP
80. How to handle exception when data table is not available in local host system or Path is not correct (Explain Statement with example)
81. Runtime dynamic settings.
82. Script generated after applying database check point.
83. Script generated at the time of setting runtime property.
84. Types of exception handling and script for that.
85. Scripting

Wednesday, April 1, 2009

QTP10

QTP 10 (code named Atlantis) has come out in early February, packed with new features and surprises. While we’ve seen previous versions of this release, we’ve taken a couple of weeks to really get to know it before writing our full in-depth review.

My personal impression of this version – Most of the new features are very well executed, but several critical flaws in the IDE improvements make this version merely worthwhile, while it could (and should) have been extraordinary. If you’re using QC, you might have a radically different opinion, since the new QC integration feature are just awesome.

Here’s an excerpt from the Summary section of the review:
QTP 10 brings many improvements to the user’s central workflows. The two main killer-features show great potential: The QC integration features make version control a viable option; and the IDE and intellisense improvements will definitely improve your productivity and efficiency. Many of the other features are significant and long awaited improvements to some of QTP’s central mechanisms, and they are mostly well executed.

However, weighing QTP 10 potential (at least for the IDE improvements) against the actual features and changes, I am left with a strong sensation of a missed opportunity. This is not to say that QTP 10 is not a worthwhile version, but that in my view it could’ve been great.

Monday, March 30, 2009

VB

Conditional Constructs
Conditional Constructs execute statements or repeat certain set of statements based on conditions.
The following conditional constructs are available in VBScript
· If – Then –Else
· Select Case

If – Then – Else Construct

The If – Then- Else Construct is used to evaluate whether a condition is true or false and depending on the result, to specify one or more statements to execute. Usually the condition is an expression that uses a comparison operator to compare one value or variable with another. The If- Then – Else statements can be nested to as many levels as needed.
For example:
Sub ReportValue(value)If value = 0 ThenMsgBox valueElseIf value = 1 ThenMsgBox valueElseIf value = 2 thenMsgbox valueElseMsgbox "Value out of range!"End If

You can add as many ElseIf clauses as you need to provide alternative choices. Extensive use of the ElseIf clauses often becomes cumbersome. A better way to choose between several alternatives is the Select Case statement.

Select Case Construct

The Select-Case structure is an alternative to If Then Else for selectively executing one block of statements from among multiple blocks of statements. The Select Case Construct makes code more efficient and readable.

A Select Case structure works with a single test expression that is evaluated once, at the top of the structure. The result of the expression is then compared with the values for each Case in the structure. If there is a match, the block of statements associated with that Case is executed.

For example:

Select Case Document.Form1.CardType.Options(SelectedIndex).Text

Case "MasterCard"

DisplayMCLogo

ValidateMCAccount

Case "Visa"

DisplayVisaLogo

ValidateVisaAccount

Case "American Express"

DisplayAMEXCOLogo

ValidateAMEXCOAccount

Case Else DisplayUnknownImage PromptAgain

End Select

Iterative Constructs
Looping allows to run a group of statements repeatedly. The loop is repeated based on a condition. The loop runs as long as the condition is true. The following looping constructs are available in VBScript.
· Do – Loop

· While – Wend

· For – Next

Do – Loop

Do – Loop statements are used to execute a block of statements based on a condition. The statements are repeated either while a condition is true or until a condition becomes true. While Keyword can be used to check a condition in a Do – Loop construct. The condition can be checked before entering into the loop or after the loop has run at least once.
The basic difference between a “Do while – Loop” and “Do - Loop while” is that the previous one gets executed only when the condition in the while statement holds true where as a “Do – Loop while” gets executed atleast once, because the condition in the while statement gets checked at the end of the first iteration.
While – Wend

The While...Wend statement is provided in VBScript for those who are familiar with its usage. However, because of the lack of flexibility in while...wend, it is recommended that you use Do...Loop instead.

For..Next

The For-Next loop can be used to run a block of statements a specific number of times. For loops use a counter variable whose value is increased or decreased with each repetition of the loop. The Step Keyword is used to increase or decrease the counter variable by the value that is specified along with it. The For-Next statement can be terminated before the counter reaches its end value by using the Exit For statement.
For example:
Dim j, total
For j = 2 To 10 Step 2

total = total + j

Next
MsgBox "The total is " & total
Arrays

An array is a contiguous area in the memory referred to by a common name. It is a series of variables having the same data type. Arrays are used to store related data values. VBScript allows you to store a group of common values together in the same location. These values can be accessed with their reference numbers.

An array is made up of two parts, the array name and the array subscript. The subscript indicates the highest index value for the elements within the array. Each element of an array has a unique identifying index number by which it can be referenced. VBScript creates zero based arrays where the first element of the array has an index value of zero.

Declaring Arrays

An array must be declared before it can be used. Depending upon the accessibility, arrays are of two types:
· Local Arrays

A local array is available only within the function or procedure, where it is declared.

· Global Arrays

A global array is an array that can be used by all functions and procedures. It is declared at the beginning of the VBScript Code.

The Dim statement is used to declare arrays. The syntax for declaring an array is as follows:

Dim ArrayName(subscriptvalue)

Where, ArrayName is the unique name for the array and SubscriptValue is a numeric value that indicates the number of elements in the array dimension within the array.

Example:

Dim No_Passengers(3)

The No_Passengers can store 4 values.

Assigning values to the array
No_Passengers(0) = 1
No_Passengers(1) = 2

No_Passengers(2) = 3

No_Passengers(3) = 4
Static and Dynamic Arrays:
VBScript provides flexibility for declaring arrays as static or dynamic.

A static array has a specific number of elements. The size of a static array cannot be altered at run time.

A dynamic array can be resized at any time. Dynamic arrays are useful when size of the array cannot be determined. The array size can be changed at run time.

Next we will deal with user defined procedures, functions and subroutines.


If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.

VBScript

What is VBScript?

VBScript is a subset of Visual Basic 4.0 language. It was developed by Microsoft to provide more processing power to Web pages. VBScript can be used to write both server side and client side scripting. (If you already know Visual Basic or Visual Basic for Applications (VBA)VB_Script_code, VBScript will be very familiar. Even if you do not know Visual Basic, once you learn VBScript, you are on your way to programming with the whole family of Visual Basic languages.)

Data types

VBScript supports only one data type called ‘Variant’. The variant data type is a special kind of data type that can contain different kinds of information. It is the default data type returned by all functions in VBScript. A variant behaves as a number when it is used in a numeric context and as a string when used in a string context. It is possible to make numbers behave as strings by enclosing them within quotes.

Variables

A variable is a placeholder that refers to a memory location that stores program information that may change at run time. A variable is referred to by its name for accessing the value stored or to modify its value.

Variable Declaration

Variables in VBScript can be declared in three ways:
  1. Dim Statement
  2. Public Statement
  3. Private Statement
For example:
Dim No_Passenger
Multiple variables can be declared by separating each variable name with a comma. For example:
Dim Top, Left, Bottom, Right
You can also declare a variable implicitly by simply using its name in your script. That is not generally a good practice because you could misspell the variable name in one or more places, causing unexpected results when your script is run. For that reason, the Option Explicit statement is available to require explicit declaration of all variables. The Option Explicit statement should be the first statement in your script.
Note:
Variables declared with Dim at the script level are available to all procedures within the script. At the procedure level, variables are available only within the procedure.
Public statement variables are available to all procedures in all scripts.
Private statement variables are available only to the script in which they are declared.

Naming Convention

There are standard rules for naming variables in VBScript. A variable name:
  1. · Must begin with an alphabetic character.
  2. · Cannot contain an embedded period.
  3. · Must not exceed 255 characters.
  4. · Must be unique in the scope in which it is declared.

Assigning Values to Variables

Values are assigned to variables creating an expression as follows: the variable is on the left side of the expression and the value you want to assign to the variable is on the right. For example:
B = 200

Scalar Variables and Array Variables

Much of the time, you only want to assign a single value to a variable you have declared. A variable containing a single value is a scalar variable. Other times, it is convenient to assign more than one related value to a single variable. Then you can create a variable that can contain a series of values. This is called an array variable. Array variables and scalar variables are declared in the same way, except that the declaration of an array variable uses parentheses ( ) following the variable name. In the following example, a single-dimension array containing 11 elements is declared:
Dim A(10)
Although the number shown in the parentheses is 10, all arrays in VBScript are zero-based, so this array actually contains 11 elements. In a zero-based array, the number of array elements is always the number shown in parentheses plus one. This kind of array is called a fixed-size array.

Constants

A constant is a meaningful name that takes the place of a number or a string, and never changes. VBScript in itself has a number of defined intrinsic constants like vbOK, vbCancel, vbTrue, vbFalse and so on.
You create user-defined constants in VBScript using the Const statement. Using the Const statement, you can create string or numeric constants with meaningful names and assign them literal values. For example:
Const MyString = "This is my string."Const MyAge = 49
Note that the string literal is enclosed in quotation marks (" "). Also note that constants are public by default.
Within procedures, constants are always private; their visibility can't be changed.

Data Driven Testing

QTP has features to enable users to perform data-driven testing. For example, data can be output to a data table for reuse elsewhere. Data-driven testing is implemented as a Microsoft Excel workbook that can be accessed from within QTP. There are two types of Data Tables available in QTP: the Global data sheet and the local data sheets. The test steps read data from these data tables in order to (for example) drive variable data into the application under test, and verify the expected result.

Wednesday, March 25, 2009

QTPTutorial

1. What is VBScript?

http://automationtoolfortesting.blogspot.com/2007/05/vbscript-in-qtp.html

2. What is difference between VBScript and VBA?

VBScript is a subset of Visual Basic for Applications, but there are still many differences:

VBScript doesn't have a debugger like Visual Basic or you can say that VBScript does not provide any debugging features. You'll resort to using lots of message boxes, instead.

Unlike Visual Basic and Visual Basic for Applications, in which the developer can define the data type of a variable in advance, all variables in VBScript are variants.

There is no integrated development environment for VBScript that parallels the IDE for Visual Basic and Visual Basic for Applications.

Because variables are untyped and code is not compiled, all external objects instantiated in VBScript code are necessarily late-bound. This has a number of implications. First, late binding typically entails a substantial performance penalty in comparison to early binding. Second, while the properties and methods of early-bound objects can be examined in Visual Basic or hosted VBA environments using the Object Browser, this is not the case with late-bound objects. Finally, the help facilities available for early-bound objects in VB and VBA (like Auto List Members and Auto Quick Info) are not available, making syntax errors more likely and ready access to good documentation all the more necessary.

3. What is the difference between function and procedure?

A function, which is called differently from a subroutine, returns a value to the code that calls it, while a procedure (subroutine) does not. Functions must be set equal to a return value:

Variable_1 = My_Function(A, B, C)

A subroutine, on the other hand, isn't set to a variable. It can be called like

My_Subroutine A, B, C
Or
Call My_Subroutine(A, B, C)

4. Is VBScript a case-sensitive or case-insensitive?

VBScript is a case-insensitive programming language; i.e. case is ignored when reading VBScript scripts. So myVar, MyVar, MYvar all refer to the same variable.

5. What are the Data Types supported by VBScript?

VBScript has only one data type called a Variant. There are different categories of information that can be contained in a Variant, called subtypes. These subtypes are:

Empty, Null, Boolean, Byte, Integer, Long Single, Double, Date/Time, Currency , String , Object and Error.

6. By default in VBScript the arguments passed to functions and subroutines are by reference or by value?

By default, arguments are passed to functions and subroutines by reference; that is, the address of the argument is provided to the function or subroutine

7. Which function allows you to instantiate an object given its programmatic identifier or ProgID?

CreateObject function

8. Discuss all the ways you know to create an Array in VBScript?

http://automationtoolfortesting.blogspot.com/2007/05/vbscript-arrays.html

9. What is Dictionary object in VBScript? Explain.

The Dictionary object stores name / value pairs (referred to as the key and item respectively) in an array.

Write the below code in a notepad and save it with a .vbs extension and run it from Command Prompt by just typing the name of the file.

Dim Beers
Set Beers = CreateObject("Scripting.Dictionary")
Beers.Add "a", "Strauss"
Beers.Add "b", "Kingfisher"
Beers.Add "c", "Budweiser"
Msgbox ("The value corresponding to the key 'b' is " & Beers.Item("b"))

The Dictionary object has many properties like Count, Item, CompareMode etc and many methods like Exists, Add, and Keys etc.

10. What is the difference between a dictionary and an array?

A dictionary can't be multidimensional but an array can be.

A dictionary has extra methods to add new items and check for existing items.

When you delete a particular item from a dictionary, all the subsequent items automatically shift up. For example, if you delete the second item in a three-item dictionary, the original third item automatically shifts up into the second-item slot.

11. What is the purpose of On Error Resume Next statement?

The On Error Resume Next statement provides you some degree of error handling by preventing program interruptions from runtime errors.

When an error occurs, by using this statement, the line of code containing the error is simply skipped over and the program continues.

On Error Resume Next statement does not correct an error, just ignore it, without even displaying the error message.

The Statement essentially has two ways it is used. First to turn off the script engine error checking:

On Error Resume Next

The second is to turn it on, thereby allowing the script engine to stop execution of a script when an error is encountered. Like so:

On Error Goto 0

12. Which object provide information about a single runtime error in a VBScript?

Err Object

13. How do you declare a class in VBScript?

http://automationtoolfortesting.blogspot.com/2007/06/vbscript-classes.html

14. What's the difference between VBScript and VB.NET?

VBScript is script - a text-based code that gets interpreted by a "host", like the Windows Script Host or IE. VB.Net is a semi-compiled language for writing java-like software.

15. Which command is used for writing text on a page?

Document.Write (text)

16. What aspects of VBScript make it safe so that a Web page using VBScript cannot destroy or corrupt information on a user's computer?

The VBScript code that comes along in a Web page cannot directly access any files on the client's computer. This prevents a Web page from making any modifications to sensitive files on the user's computer. VBScript is also very safe in that it doesn't give programmers the ability to create unrecoverable crashes by virtue of its language syntax.

17. Write the code required within a procedure to create a variable for storing your name with VBScript code. Assign your name to that variable.

Dim Name
Name = "Harry Manis"

18. Assume you have a variable called Age that contains an age provided by the user. Write the code that ensures that the user has entered a number as her age. If the user hasn't entered a number, tell her she needs to enter her age correctly.

If IsNumeric(Age) = False Then
MsgBox "The size should be a number. Please type it again."
End If

19. Write a VBScript procedure that converts feet to inches. Hint: There are 12 inches in a foot.

Option Explicit

Sub feet_to_inch()
Dim Inches, Feet
Feet=inputbox("Enter feet value ")
Inches = Feet * 12
MsgBox "There are " & Inches & " inches in " & Feet & " feet."
End Sub

Call feet_to_inch()

20. Why is the use of Exit Do or Exit For statements within loops discouraged?

These statements are acceptable for specific conditions, but they often make code less readable, which makes it difficult for others who look at your code to know what's really going on. If you make sure the only way out of a loop is to not satisfy the loop's condition, it's much easier to follow your code. Often, breaking out of a loop by force with an exit statement is a sign of a poorly constructed loop with a condition that does not meet your goals. Take a look at the loop structure and condition again to make sure you're not leaving something out.

21. Give an example of if...then...elseif statement.

http://automationtoolfortesting.blogspot.com/2007/05/vbscript-conditional-statements.html

22. What is the use of Property Let and Property Get procedure?

http://automationtoolfortesting.blogspot.com/2007/08/vbscript-property-let-property-get.html

23. Explain about VBScript coding conventions?

http://msdn.microsoft.com/hi-in/library/ektke1b0(en-us,VS.85).aspx

24. What is the difference between VB Debugger and the Script Debugger?

Difference between VB Debugger and the Script Debugger:

No "on the fly" editing
Because the scripting window is read-only, you cannot edit the code during execution, as you can most of the time with VB.

No Instant Watch (Shift-F9)
The VB debugger's instant watch facility, which allows you to highlight a variable in your code, press Shift-F9, and see the value of the variable, is not available in the Script Debugger.

Cannot set watches
Watches do not exist in the Script Debugger.

Cannot set the next statement
Using the VB Debugger, you can place the cursor on a line of code and, by clicking CTRL-F9, have program execution resume at that line. This is particularly useful to backtrack or to re-execute a section of code. Unfortunately, this feature is not available in the Script Debugger.


Also download the above questions, print them and read in your free time.

Subscribe to QTP RSS Feed to get more useful & interesting stuff.










Monday, March 23, 2009

QTP

Quick Test Professional (QTP) is an automated functional Graphical User Interface (GUI) testing tool created by the HP subsidiary Mercury Interactive that allows the automation of user actions on a web or client based computer application. It is primarily used for functionalregression test automation. QTP uses a scripting language built on top of VBScript to specify the test procedure, and to manipulate the objects and controls of the application under test."
Quick Test Professional (QTP) is an automated functional Graphical User Interface (GUI) testing tool created by the HP subsidiary Mercury Interactive that allows the automation of user actions on a web or client based computer application. It is primarily used for functionalregression test automation. QTP uses a scripting language built on top of VBScript to specify the test procedure, and to manipulate the objects and controls of the application under test."