Search This Blog

Monday, September 6, 2010

How to become a QC Administrator - QC Administration Terminology

Site Administrator: A User who can access the "Quality center Site administration" Tool.

TD Admin or Project Administrator:A User who can Customize a Specific QC Project .

Quality Center Site Administration: A tool that allows a site Administrator to become a TD Admin,Create and modify Projects,Add Users and Configure QC.Project level Customization is excluded from this tool.

Sunday, September 5, 2010

Requirements for Load Testing

Questions that need to be answered for coming up with test scenarios:

1.What would be the max number of users logged in and using the system at one time?
2.Which transactions (features) are most commonly used?
3.What would be the max number of users processing a transaction at one time?
4.How many of each transaction takes place per day?
5.What time of day do certain transactions take place?
6.What are the transactions acceptable response times?
7.What connection speeds would be used by how many users for each transaction?
8.What transactions would be taking place at the same time and how many?

Thursday, September 2, 2010

Folder Structure in QTP Package

The high level explanation could be as follows:

1.

2.
a. Action folders : , , ....
b. Files inside the :
1. .cfg file -
This holds the run time information like addins loaded, user information, etc.

2. .prm file -
Hlds the information about the number of iterations and the parameters that are used within the script / action.

3. .usr file -
This will be generated to hold the name of the script, the objectRepository info, etc.

4. .lck file -
This is a lock file.

5. .mtr file -
(No idea)

6. .xls sheet -
The default sheet that holds the parameters used within the script.

7. .prm.bak file -
backup file.

8. .usp file -
Stores some RUnLogic information for the script.

9. thin_usr.dat file -
similar to the thick usr file. The diff is not clear exactly.

10. thick_usr.dat file -
Stores high level info about all the above and below files indicating what set of files was created, etc.

11. .tsp file -
??

3. folder:
This is a default folder that is created to hold the following:

a. folder:
This will hold all the active screen files which are zipped, pertaining to that action.

b. Resource.mtr file -
This file holds info regarding the object rep used, the shared libraries used, and possibly maitains a track of how the script is being accessed through the code. Ie. the call chain.

c. Script.mts -
This is the script file actually.

d. .tsr -
The object rep file if used in per action mode.

e. The result file.

f. The action excel sheets.

The subsequent action folders hold similar set of files.

Basic guide lines and check list for web testing

Aspects to cover: Functionality Usability User Interface Server side interface Compatibility Security Performance
LINKS: To check for all the links in the web site 1) All hyper links
2) All Internal links 3) All mail links 4) Check for Orphan pages
5) Check for broken links FORMS: To check for the integrity of submission of all forms 1) All field level checks 2) All field level validations
3) Functionality of create,modify,delete,and view
4) Handling of wrong inputs
5) Default values if any 6) Optional Vs Mandatory fields

COOKIES: Check for the cookies that has to be enabled and how it has to be expired

WEB INDEXING: Depending on how the site is designed using meta tags, frames, HTML Syntax, dynamically created pages, Passwords or different languages, our site will be searchable in different ways

DATABASE: Two types of errors occurs in WEB Application
1) Data Integrity: Missing or wrong data in Table
2) Output Errors: Errors in writing, editing, or reading operation in the table

USABILITY: How simple customer can browse the web site NAVIGATION:
1) Navigation describes the way user navigate with in a webpage, between different user interface controls (buttons, text boxes, combo boxes, drop down lists………etc) 2) Application navigation is proper through tabs
3) Application navigation is proper through mouse
4) Any hot keys, control keys to access menus

CONTENT: 1) Correctness is whether the information is truthful or contains mis information
2) The accuracy of the information is whether it is with out grammatical or spelling errors
3) Spelling and grammar
4) Updated information (contact details, mail ID’s, help reports)

GENERAL APPEARANCE: 1) Page appearance 2) Colour, font size 3) Frames 4) Consistant designs 5) Symbols and logo’s

SERVER SIDE INTERFACE
: 1) Verify that communication is done correctly, WEB Server – Application Server, Application Server – database Server and vice versa
2) Compatibility of Server software, hardware, network connections
3) Database compatibility
4) External interfaces if any CLIENT SIDE COMPATIBILITY: Platforms: XP, NT, UNIX, LINUX, Solaris, Macintosh Browsers: IE (3.x, 4.x, 5.x), NET Scape, AOL Browser Settings

Error Number Descriptions in QTP

507 An exception occurred
449 Argument not optional
17 Can't perform requested operation
430 Class doesn't support Automation
506 Class not defined
11 Division by zero
48 Error in loading DLL
5020 Expected ')' in regular expression
5019 Expected ']' in regular expression
432 File name or class name not found during Automation
92 For loop not initialized
5008 Illegal assignment
51 Internal error
505 Invalid or unqualified reference
481 Invalid picture
5 Invalid procedure call or argument
5021 Invalid range in character set
94 Invalid use of Null
448 Named argument not found
447 Object doesn't support current locale setting
445 Object doesn't support this action
438 Object doesn't support this property or method
451 Object not a collection
504 Object not safe for creating
503 Object not safe for initializing
502 Object not safe for scripting
424 Object required
91 Object variable not set
7 Out of Memory
28 Out of stack space
14 Out of string space
6 Overflow
35 Sub or function not defined
9 Subscript out of range
5017 Syntax error in regular expression
462 The remote server machine does not exist or is unavailable
10 This array is fixed or temporarily locked
13 Type mismatch
5018 Unexpected quantifier
500 Variable is undefined
458 Variable uses an Automation type not supported in VBScript
450 Wrong number of arguments or invalid property assignment

What is ER Diagram

The Entity-Relationship (ER) model was originally proposed by Peter in 1976 [Chen76] as a way to unify the network and relational database views.

Simply stated the ER model is a conceptual data model that views the real world as entities and relationships. A basic component of the model is the Entity-Relationship diagram which is used to visually represents data objects.

Since Chen wrote his paper the model has been extended and today it is commonly used for database design For the database designer, the utility of the ER model is:

it maps well to the relational model. The constructs used in the ER model can easily be transformed into relational tables.
it is simple and easy to understand with a minimum of training. Therefore, the model can be used by the database designer to communicate the design to the end user.

In addition, the model can be used as a design plan by the database developer to implement a data model in a specific database management software.

model was originally proposed by Peter in 1976 [Chen76] as a way to unify the network and relational database views.

Simply stated the ER model is a conceptual data model that views the real world as entities and relationships. A basic component of the model is the Entity-Relationship diagram which is used to visually represents data objects.

Since Chen wrote his paper the model has been extended and today it is commonly used for database design For the database designer, the utility of the ER model is:

it maps well to the relational model. The constructs used in the ER model can easily be transformed into relational tables.
it is simple and easy to understand with a minimum of training. Therefore, the model can be used by the database designer to communicate the design to the end user.

In addition, the model can be used as a design plan by the database developer to implement a data model in a specific database management software.

What is ETL

ETL is a short for Extract, Transform and Load. It is a data integration function that involves extracting the data from outside sources , transforming it into business needs and ultimately loading it into a datawarehouse

ETL is an abbreviation for "Extract, Transform and Load".This is the process of extracting data from their operational data sources or external data sources, transforming the data which includes cleansing, aggregation, summarization, integration, as well as basic transformation and loading the data into some form of the data warehouse.

E: Extraction of data from the homogeneous/heterogenous sources.
T: Transforming/modifying the source data by applying some transformations like Filter, Expression, Router, Joiner,
L: Loading the Transformed data into corresponding Target tables.

Wednesday, September 1, 2010

What is FrameWork

It basically depends upon the type of Framework being used - datadriven, modular, keyword based or hybrid Framework.

Test automation Framework is a set of assumptions, concepts and practices that provide support for automated software testing.

Test script modularity Framework:

The test script modularity Framework requires the creation of small, independent scripts that represent modules, sections, and functions of the application-under-test. These small scripts are then used in a hierarchical fashion to construct larger tests, realizing a particular test case.
It is called as modular since we are breaking the scripts into modules - a few of which are compile modules or reusable. This is the simplest of all Frameworks.

Data Driven Frameworks:

Test scripts are executed and verified based on the data values stored in one or more central data sources or databases. These databases can range from datapools, odbc sources, csv files, excel files, dao objects, ado objects, etc.
The establishment of several interacting test scripts together with their related data results in a Framework used for the methodology. In this Framework, variables are used for both input values and output verification values: navigation through the program, reading of the data sources, and logging of test status and information are all coded in the test script.
Thus, the logic executed in the script is also dependant on the data values.


Keyword-driven Framework:

Keyword-driven Framework separates much of the programming work from the actual test steps so that the test steps can be developed earlier and can often be maintained with only minor updates, even when the application or testing needs change significantly.
It consists of driver, control scripts etc

It is set of rules defined for developping and organising the test scripts.There are diffrent types of Framework are available namely modularized type of framework, library based, data driven, keyword driven and hybrid framework.

You can use any of these Framework for automation. It depends on the project and its criticality.

Hybrid Framework:

Hybrid Framework represents combination of other different framework in order to maintain code/scripts. You can choose some external files for updation of fields in the projects/application(say excel sheets or text files) and you need to import the file to the script, so whenever u want to update the script by different set of value you just need to update the external files which will effect on the automation script

How to run QTP Scripts from QC

Open QC,
Create a new Subject in Test Plan

Then place all your QTP scripts in folder
Open QTP and file - > Quality Center Connection
Enter url
Connect
Enter QC UserID and Password
Project : Domain & Project
Open the script you wish to run, click on File - > Save As ....select Quality Center button in the right botton corner
Seelct the relevant subject folder created before in QC
Click on OK


Login to QC, in Test lab, select the testscripts uploaded and click on Run

Wednesday, August 25, 2010

Excel Report - Excel Report Generator WithOut Using Quality Center

NOW u CAN generate reports from Excel Sheet without logging in to QC.
JUST give a click on Excel ........

It will WORK for ANY Project ANY Organization

PLZ wait for further details....or CONTACT ch.girish.ch@gmail.com

HP QTP 10.0 and QC 10.0 Latest Certification Questions

Hi, If anybody wants to write for QTP 10.0 and QC 10.0 Certification Question DUMPS....PLZ send a mail to my mail ID: ch.girish.ch@gmail.com

If you are thinking of getting certifications for QTP 9.2 and QC 9.2 then forget it, they are expired.......

Monday, August 23, 2010

How to Copy SQL query from a QC Generated Report or Graph

Subject: Copy SQL query from a QC Generated Report or Graph?

Can you get access to the underlying SQL query on a QC generated Report or Graph? We have several graphs that are only used for the data grid. We want to be able to run a Excel Report to generate this graph. Is the SQL stored in the database somewhere where it can be accessed?

Solution:

The Profiler tool that comes with SQL Server is useful for determining what call was made on the database by an event on a client tool. For example, if you require a specific SQL statement to get data from Quality Center, you can set up the Profiler and run a report from the Quality Center client. The Profiler will provide you with the SQL statement which was sent to the database for that report. You can then take this statement and customise it as required.

7.4.1.1 Loading the Profiler

1. Remote access into the database server that you require (e.g. PARV01110093)
2. Select Start > All Programs > Microsoft SQL Server > Profiler. The Profiler will load.
3. Select File > New > Trace¦ Provide login details for the correct database instance.



Trace Configuration

General Tab

¢ Give the trace a name.
¢ Template Name SQLProfilerStandard or SQLProfilerTSQL

Events Tab
Add the following event classes:
Stored Procedures
RPC: Starting
SP: StmtCompleted
SP: StmtStarting
TSQL
SQL: StmtCompleted
SQL: StmtStarting

Data Columns Tab
¢ Select the following data items:
EventClass
NTUserName
DatabaseID
TextData
SPID
StartTime

Filters Tab
Filter the trace to report only on a specific database
DatabaseName
Like


Running the Trace

As an SQL trace can contain an enormous amount of data, the more specific you can configure it the better. It is also important to start the trace immediately before the client event is executed. Make a note of when the client event is triggered to help you locate it in the trace data.

1. Load the Profiler
2. Configure the trace
3. Load the client application
4. Run the event that you wish to trace
5. Click the Run button on the Profiler
6. The trace will start running. When the tool client process has completed, click the red Stop button on the Profiler toolbar.

Please consult your DBA before running the profiler.



Thursday, August 19, 2010

HP QTP 10.0 and QC 10.0 Certification Details



Basically HP has come up with two types of Certifications, HP AIS(Foundation) & HP ASE(Advanced)
1. HP AIS Stands for Hewlett Packard Accredited Integration Specialist
* Below Exams need to be cleared for accomplishing HP AIS
--> HP0 M16 (QTP 9.2) -These got Expired
--> HP0 M15 (QC 9.0) -These got Expired
OR

--> HP0-M39 (QTP 10.0)
--> HP0-M31(QC 10.0)

HP0-M31 (old HP0-M15) and HP0-M39 (old HP0-M16)





2. HP ASE Stands for Hewlett Packard Accredited Systems Engineer
* HP AIS clearance is mandatory for appearing HP ASE

Before appearing HP AIS Certification exams, follow the below steps

Points to be known for appearing HP AIS Certification(QTP & QC).


Step 1: Navigate to the HP Partner Portal using the below link
http://h20375.www2.hp.com/portal/site/publicpartnerportal-ap/in/en/

Step 2: Click on Register link & complete the registration process.

Step 3: You will receive an email regarding your User Id & a Link Create New Password from Premium.support@hp.com & create a new pwd.

Step 4: Login into HP Partner Portal by your User Id & password , click on Train & Certify --> Request Access, it will take around 3 business days for creation of HP Learner Id.

Step 5: HP Partner Portal -->Train & Certify --> Access the Learning Center ->My Profile --> Edit Profile Snapshot change the required ISD time frames --> Save

Step 6: Login to HP Partner Portal --> Train & Certify --> Access the Learning Center --> Note down your HP Learner Id --> Contact Prometric Testing Center in any NIIT institute in your city for appearing the HP AIS exam.


After clearing the HP AIS Certification exams, below steps are required for achieving the HP AIS Certification - Soft Copy

Step 7: Once you have cleared HP0 M15 & HP0 M16 Exams, navigate to below path for knowing your Exam Successful Completion Status.
Login to HP Partner Portal -->Train & Certify --> Access the Learning Center -->My Learning --> My Transcripts

Step 8: Login to HP Partner Portal -->Train & Certify --> Access the Learning Center -->My Learning -->My Certification
Click on Add Certification & search for required certification (AIS HP Quality Center V9) & select the checkbox & then your certification will be added to the Certifications table & status field will be given as Assigned.

Step 9: Login to HP Partner Portal -->Train & Certify --> Access the Learning Center -->My Learning -->My Certification--> In Certification table,
check the Status field, if it is updated as Acquired in 1 week your certification will be uploaded into your HP Learner id Account.

Step 10: After 1 week , Login into HP Partner Portal --> Certification Program click on My E-Certificates, In E-Certificates HP Certified Professional Program page AIS HP Quality Center V9 Professional Letter A4 can be seen.

Step 11: click Letter or A4 & Save the soft copy/attachment into your system

How to view Results if error occurs while trying to open Results



Two files which got affected in displaying Results:
1) Results.xml and 2) GeneralInfo.ini.

Results.xml – contains all the test result data in the structured format. Due to abnormal closing of QTP, some tags in this xml file does not close properly, due to which test result viewer is not able to read it properly.

GeneralInfo.ini – once QTP execution is successfully done, it creates this ini file which initiates the result viewer and contains the required information to populate the result.

So whenever you get such an error, go to your result path (report folder). You will notice that there is no general info file has been created. In case it is there trying opening in notepad. You will find that no data is there. That means you will have to create this file in order to view the result.

Create a txt file in your report folder name it as ‘GeneralInfo.ini’ and Open it in notepad.

Write the text mentioned below –

[General] ‘ini file tag. Keep this intact
Product= ‘name of the product which will be QuickTest Professional
Version = ‘Version of your QTP
Total = ‘the number of total lines in the xml file for result (explained below)
Title= ‘Script Title
OSVersion = ‘version of operating system
TestLocation= ‘Test Path

Parameter ‘Total’ can be retrieved from the incomplete results.xml file.

Open the file in any file editor. Go to the end of the file. Search the first tag which contains from bottom.You will see a value assigned there to rID as in the below piece of xml.




Wednesday, August 18, 2010

Automated Regression Testing Challenges in Agile Environment

Abstract
Recently, when I wanted to start my new Automated Testing Project with four resources, I thought of applying any one of the Agile methodologies. But I was not able to continue because, a series of questions were raised inside my mind. The questions are like “Is it possible to use Agile methodologies in Automated Testing?”, “Can I use traditional tools”, “Should I have to go for open-source tools”, “What are the challenges I have to face if I am implementing automation in Agile Environment”. In this article let us analyze some of challenges we face while implementing Automation with Agile methodologies. Automated testing in the Agile environment stands a risk of becoming chaotic, unstructured and uncontrolled.

Agile Projects present their own challenges to the Automation team; Unclear project scope, Multiple iterations, Minimal documentation, early and frequent Automation needs and active stakeholder involvement all demand lot of challenges from the Automation Team. Some of these challenges are:

Challenge 1: Requirement Phase
Test Automation developer captures requirements in the form of “user stories”, which are brief descriptions of customer-relevant functionality.

Each requirement has to be prioritized as follows:

High: These are mission critical requirements that absolutely have to be done in the first release
Medium: These are requirements that are important but can be worked around until implemented.
Low: These are requirements that are nice-to-have but not critical to the operation of the software.

Once priories are established, the release “iterations” are planned. Normally, each Agile release iteration takes between 1 to 3 months to deliver. Customers/software folks take liberty to make too many changes to the requirements. Sometimes, these changes are so volatile that the iterations are bumped off. These changes are greater challenges in implementing Agile Automation testing process.

Challenge 2: Selecting the Right Tools

Traditional, test-last tools with record-and-playback-features force teams to wait until after the software is done. More over, traditional test automation tools don’t work for an Agile context because they solve traditional problems, and those are different from the challenges facing Agile Automation teams. Automation in the early stages of an agile project is usually very tough, but as the system grows and evolves, some aspects settle and it becomes appropriate to deploy automation. So the choice of testing tools becomes critical for reaping the efficiency and quality benefits of agile.

Challenge 3: Script Development Phase

The Automation testers, developers, business analysts and project stakeholders all contribute to kick-off meetings where “user-stories” are selected to next sprint. Once the “user-stories” are selected for the sprint, they are used as the basis for a set of tests.

As functionality grows with each iteration, regression testing must be performed to ensure that existing functionality has not been impacted by the introduction of new functionality in each iteration cycle. The scale of the regression testing grows with each sprint and ensures that this remains a manageable task the test team use the test automation for the regression suite.

Challenge 4: Resource Management

The Agile approach requires a mixture of testing skills, that is, test resource will be required to define unclear scenarios and test cases, conduct manual testing alongside developers, write automated regression tests and execute the automated regression packages. As the project progresses, specialist skills will also be required to cover further test areas that might include integration and performance testing. There should be an appropriate mix of domain specialist who plan and gather requirements. The challenging part in the Resource management is to find out test resources with multiple skills and
allocate them.

Challenge 5: Communication

Good communication must exist among Automation testing team, developers, business analysts and stake holders. There must be highly collaborative interaction between client and the delivery teams. More client involvement implies more suggestions or changes from the client. It implies more bandwidth for communication. The key challenge is that the process should be able to capture and effectively implement all the changes and data integrity needs to be retained. In traditional testing, developers and testers are like oil and water, but in agile environment, the challenging task is that they both must work together to achieve the target.

Challenge 6: Daily Scrum Meeting

Daily Scrum Meeting is one of the key activities in Agile Process. Teams do meet for 15 minutes stand up sessions. What is the effectiveness of these meetings? How far these meetings help Automation practice Developers?

Challenge 7: Release Phase

The aim of Agile project is to deliver a basic working product as quickly as possible and then to go through a process of continual improvement. This means that there is no single release phase for a product. The challenging part lies in integration testing and acceptance testing of the product.

If we can meet these challenges in a well optimized manner, then Automated Regression Testing in Agile environment is an excellent opportunity for QA to take leadership of the agile processes. It is better placed to bridge the gap between users and developers, understand both what is required, how it can be achieved and how it can be assured prior to deployment. Automation practice should have a vested interest in both the how and the result, as well as continuing to assure that the whole evolving system meets business objectives and is fit for purpose.

How to Manage Automation Expectations:

How to Manage Automation Expectations:
In order to implement a successful automation effort, testers need to educate management on a number of different issues. Educating management on these issues could mean the difference between a successful automation effort and a failed automation attempt.


One such important issue addresses integrating test automation into the entire development process. Testers need to educate senior management as well as script writers on how a specific tool will fit into their software development environment and software development life cycle. It is equally important to remind everyone that manual testing does not end when automation is implemented.


Another issue concerns the purchasing of tools and their impact on test planning. Test planning, planning what to test and how to test, becomes much more complex and more important when a tool is purchased. For example, test automation is rarely justified for all testing. The tester needs to determine what tasks make sense to automate and what does not make sense to automate.


Moreover, the organization needs to understand that automation does not eliminate manual efforts on the part of testers. Testers need to maintain automation scripts and verify the execution of automated scripts. This is manual work that needs to be factored into the test team's testing activities.


In addition, in order to automate successfully, testers need training and time to master the test tools. Many managers view the test tools as simple capture / playback programs which a tester can learn and implement in his spare time. This is a misconception. Successful test automation frequently requires the use of complex tools — tools which are much more complex than the just capture / replay tools. In order to use these tools effectively, testers need considerable training. Management needs to be committed to training testers on these tools and to establishing the infrastructure in which the tool operates.


Also successful test automation requires the involvement of the software development team as well as testers. In the past, developers and testers had minimal contact. Frequently, the philosophy was to "throw code over the wall and see if it works". This type of interaction does not work when automating the testing process. Developers and testers need to work much more closely together. Developers have to provide support personnel and technical information on their development methods. They can be asked to use the automation tools during their unit and integration testing. More troubling to the developer will be that test automation may raise concerns about the testability of their code. This especially will be the case if standards are not followed, or if developers use odd, homegrown or even very new libraries / objects.


The organization’s project management team must have a clear understanding about the types of roles and responsibilities required for a successful automation effort. The creation of the test environment starts when an organization purchases hardware and installs a tool. Then the test team and development team need to work together to build and maintain a test automation environment that may include dedicated servers, workstations, databases and the like. Management needs to include development of the test environment in the overall project plan. They should also budget for the resources needed to successfully automate testing.


Successful tool automation depends not only on the test tools but also on a standard testing process and the right test team roles, duties and skills. Tools, process and test teams are the three essential legs of the test automation stool.


Moreover, the automation test team needs to have a blend of testing, programming, and tool knowledge. If an organization wants to reap the automation benefits promised by tool vendors, it needs to use the tool as a complement to manual testing. It also means adopting a strong test methodology and training the test team on the ins and outs of the selected tool in an organization's unique development environment.

How to Generate Excel Reports in QC 10.0

To Create Excel reports -We need to have access for DashBoard module in QC 10.0
For QC 9.2 the reports option is under Tools - Home Page
and For QC 9.0 there is no option to generate Excel Reports

Navigation - QC 10.0 -
1) Go to DashBoard module
2) Select Excel Report in top left corner
3) Enter Report Name
4) Write Query under Query Tab
5) Add macro under Post Processing Script
6) Set the Status to "Ready"
7) For test purpose we can use Query Generator
8) For viewing of Tables we can use Query Generator
9) Click Generate Query
10)There you go report

Tuesday, August 17, 2010

Advantages and Disadvantages of Dictionary Objects

Dictionary Object

Dictionary Object stores data key, item pairs. A Dictionary object stores the items in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array.



Adavntages of using it in QTP:

1. can be used as Global variable declaration. so that any test can access the values from it in the run time.

2. You can store and retrive any number of run time values in to dictonary.

3. It is one of the Parameterization techique we can use in QTP



Disadvantages:

we can not specify the values in the desingn time like Datatable , Action parameters, environment variable.

So it is useful only in Run time , not design time

What is Dictionary Object - Overview

Dictionary object allows storing key value pairs. A dictionary object can be used for easy lookup of values. Dictionary is a not a QTP specific functionality and is available in normal VBScript as well.

Creating the Dictionary
A dictionary object can be created using CreateObject for COM class “Scripting.Dictionary”. The code below shows how to create the dictionary object in QTP


'Create the Dictionary Object
Set oDict = CreateObject("Scripting.Dictionary")


Below table shows list of methods that dictionary objects supports.
Method Description
Add (key, item)- Adds a key and item pair to a Dictionary object.
Exists(key)- Returns true if a specified key exists in the Dictionary object, false if it does not
Items() - Returns an array containing all the items in a Dictionary object
Keys() - Returns an array containing all existing keys in a Dictionary object.
Remove(key) - Removes a key, item pair from a Dictionary object
RemoveAll() - The RemoveAll method removes all key, item pairs from a Dictionary object.

Count - Returns the number of items in a Dictionary object. Read-only.
Item Sets or returns an item for a specified key in a Dictionary object. Read/write
Key(Key) Sets a key in a Dictionary object.

Adding Items to Dictionary:
There are two ways to Add items to dictionary. One is to use the Add method and another is to use the Item property. Both the methods are shown in code below
'Method 1 for Adding items to dictionary
'Add items to dictionary
oDict.Add "CA", "California"
oDict.Add "LA", "Los Angeles"

'The below line will throw an error as LA key already exist
oDict.Add "LA", "Los Angeles 2"

'Method 2 for adding items to dictionary
oDict.Item("CA") = "California"

'Item is the default property so ".Item" is not required
oDict("LA") = "Los Angeles"

'No Error this time as we are actually using the
'Item property and not the Add method
oDict("LA") = "Los Angeles 2"100 Miles From Memphis

Monday, August 16, 2010

Checklist for web services

Design Considerations

Design chunky interfaces to reduce round trips.

Prefer message-based programming over remote procedure call (RPC) style.

Use literal message encoding for parameter formatting.

Prefer primitive types for Web service parameters.

Avoid maintaining server state between calls.

Consider input validation for costly Web methods.

Consider your approach to caching.

Consider approaches for bulk data transfer and attachments.

Avoid calling local Web Services.
Connections
**********************************************************

Configure the maxconnection attribute.

Prioritize and allocate connections across discrete Web services.

Use a single identity for outbound calls.

Consider UnsafeAuthenticatedConnectionSharing with Windows Integrated Authentication.

Use PreAuthenticate with Basic authentication.
Threading
********************************************************************

Tune the thread pool using the formula for reducing contention.

Consider minIoThreads and minWorkerThreads for intermittent burst load.
One Way (Fire and Forget) Communication
**********************************************************************

Consider using the OneWay attribute if you do not require a response.
Asynchronous Web Methods
*********************************************************************

Use asynchronous Web methods for I/O operations.

Do not use asynchronous Web methods when you depend on worker threads.
Asynchronous Invocation
*********************************************************************

Consider calling Web services asynchronously when you have additional parallel work.

Use asynchronous invocation to call multiple unrelated Web services.

Call Web services asynchronously for UI responsiveness.
Timeouts
*********************************************************************

Set your proxy timeout appropriately.

Set your ASP.NET timeout greater than your Web service timeout.

Abort connections for ASP.NET pages that timeout before a Web services call completes.

Consider the responseDeadlockInterval attribute.
WebMethods
*********************************************************************

Prefer primitive parameter types.

Consider buffering.

Consider caching responses.

Enable session state only for Web methods that need it.
Serialization
*********************************************************************

Reduce serialization with XmlIgnore.

Reduce round trips.

Consider XML compression.
Caching
*********************************************************************

Consider output caching for less volatile data.

Consider providing cache-related information to clients.

Consider perimeter caching.
State Management
*********************************************************************

Use session state only where it is needed.

Avoid server affinity.
Attachments
*********************************************************************

Prefer Base64 encoding. Direct Internet Message Encapsulation (DIME) is a supported part of Web Services Enhancements (WSE), but Microsoft® is not investing in this approach long-term. DIME is limited because the attachments are outside the SOAP envelope.
COM Interop
*********************************************************************

Avoid single-threaded apartment (STA) COM objects.

Sunday, August 8, 2010

VB Script - 3

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.


This post is third in the VB Script and QTP series.

Here we shall talk about user defined procedures.

Procedures are set of executable statements.

In VBScript, there are two types of procedures:

Sub Procedures
Function Procedures




Sub Procedures

A sub procedure is a series of VBScript statements, enclosed by Sub and End Sub statements which perform actions but do not return a value. A sub procedure can take arguments. If a sub procedure doesn’t receive any arguments, its Sub statement must include an empty parenthesis().

The following Sub procedure uses two intrinsic, or built-in, VBScript functions, MsgBox and InputBox , to prompt a user for information. It then displays the results of a calculation based on that information. The calculation is performed in a Function procedure created using VBScript. The Function procedure is shown after the following discussion.

Sub ConvertTemp()
temp = InputBox("Please enter the temperature in degrees F.", 1)
MsgBox "The temperature is " & Celsius(temp) & " degrees C."
End Sub

Function Procedures

A function procedure is a series of VBScript statements enclosed by the Function and End Function statements. A function procedure is similar to a sub procedure but it can return value to the calling function. A function procedure can take arguments (constants, variables or expressions that are passed to it by a calling procedure). If a function procedure has no arguments, it Function statement must include an empty set of parenthesis. A function returns a value by assigning a value to its name in one or more statements of the procedure. Since VBScript has only one base data type, a function always returns a variant.

In the following example, the Celsius function calculates degrees Celsius from degrees Fahrenheit. When the function is called from the ConvertTemp Sub procedure, a variable containing the argument value is passed to the function. The result of the calculation is returned to the calling procedure and displayed in a message box.

Sub ConvertTemp()
temp = InputBox("Please enter the temperature in degrees F.", 1)
MsgBox "The temperature is " & Celsius(temp) & " degrees C."
End Sub

Function Celsius(fDegrees)
Celsius = (fDegrees - 32) * 5 / 9
End Function

Tips:
To get data out of a procedure, you must use a Function. Remember, a Function procedure can return a value; a Sub procedure can't.
AFunction in your code must always be used on the right side of a variable assignment or in an expression.
To call a Sub procedure from another procedure, type the name of the procedure along with values for any required arguments, each separated by a comma. The Call statement is not required, but if you do use it, you must enclose any arguments in parentheses.
The following example shows two calls to the MyProc procedure. One uses the Call statement in the code; the other doesn't. Both do exactly the same thing.

Call MyProc(firstarg, secondarg)

MyProc firstarg, secondarg

Notice that the parentheses are omitted in the call when the Call statement isn't used.

VB Script - 2

This is in continuation from VB Script and QTP - Part1 on our series of posts on VB Script. Here, we will dwell upon conditional constructs, iterative constructs and arrays.

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 Then
MsgBox value
ElseIf value = 1 Then
MsgBox value
ElseIf value = 2 then
Msgbox value
Else
Msgbox "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

VB Script - 1

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), 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:
Dim Statement
Public Statement
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:
• Must begin with an alphabetic character.
• Cannot contain an embedded period.
• Must not exceed 255 characters.
• 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.

Wednesday, August 4, 2010

How to send a key command to a Web object in QTP

Some Web objects will perform actions when certain key commands, such as ALT+RETURN, are entered. These Web objects do not have a type method associated with them that can be used to replay these keys. How can the key combination be replayed?

________________________________________
Solution: Use the Windows Scripting SendKeys method
1. Create a WScript.Shell object.
2. Activate the browser in which you want to execute the keys.
3. Use the SendKeys method to type the key combination.
Example:
‘ This code executes the CTRL+F key combination (search) on a browser.
Set WshShell = CreateObject(”WScript.Shell”)
WshShell.AppActivate “Put the label of the browser” ‘ Activate the browser window
wait(3)
WshShell.SendKeys “^f” ‘ The caret (^) represents the CTRL key.
wait(2)
object.SendKeys(string)
object A WshShell object.
string The string value indicating the keystroke(s) you want to send.
The SendKeys method will send keystroke(s) to the active window. To send a single character (for example, x), use “x” as the string argument. To send multiple characters (for example, abc), use “abc” as the string argument. You can also send special characters such as SHIFT, CTRL, and ALT, which are represented by the plus sign (+), the caret (^), and the percent sign (%), respectively.
For more information on the SendKeys method and other special keys, such as the backspace or a function key, please refer to the MSDN SendKeys Method page.
====================================================================================================
‘ Name: KeyboardShortCut

‘ Input:
‘ ByRef Key As Variant - The keyboard key to be typed.
‘ ByRef Pane As Variant - The window/pane to type in.
‘ Purpose: To type keyboard input onto the open window.
‘====================================================================================================
Function KeyboardShortCut (Key)
dim obj
Set obj = Window(”Window Name” ).WinObject(”Object”)
obj.type Key
Environment(”LastResult”) = “Success”
End Function
Solution2: Pressing Function keys should be recorded automatically
Directly recording on the application and pressing the Function Keys (F1, F2, etc.) should generate code for replay.
Example:
‘Here is an example recorded against Notepad:
Window(”Notepad”).Activate
Window(”Notepad”).WinEditor(”Edit”).Type micF5
If the above does not work, then you can use DeviceReplay to simulate pressing keyboard keys.
Example:
‘Here is an example that does the same thing above, but used DeviceReplay.
Set obj = CreateObject(”Mercury.DeviceReplay”)
Window(”Notepad”).Activate
obj.PressKey 63
Note:
The PressKey method uses the appropriate ASCII or IBM Scan Code value for the key. “63″ is the IBM Scan Code value for F5.

Sample Selenium Test Suite

TestSuite.html
Test suite for the whole application
Access main page
Login to application
Change address
Logout from application











Open fire fox not selenium IDE and paste this link in the address bar

chrome://selenium-ide/content/selenium/TestRunner.html?baseURL=http://localhost&test=file:///dir/testsuite.html&auto=true



replace http://localhost with the baseURL of your server






Running Test Suite from command line
If you want to run a number of tests from the command line - for example, as an acceptance test step, or as a part of the checkin, you have a couple of options.
1) Selenium RC provides convenient command-line support for running HTML Selenese tests from the command-line or with Ant: http://www.openqa.org/selenium-rc/selenese.html
2) Create a batch file that launches Firefox pointed to the suite. For example, on Windows, my batch file looks like:
"C:\Program Files\Mozilla Firefox\firefox.exe" -chrome "chrome://selenium-ide/content/selenium/TestRunner.html?test=file:///C:/tests/AllTests.html&auto=true&baseURL=http://mysite.com " -height 900 -width 900

Selenium Commands - Part 9

U

uncheck(locator)
Arguments:
• locator - an element locator
Uncheck a toggle-button (checkbox/radio)


uncheckAndWait(locator)
Generated from uncheck(locator)
Arguments:
• locator - an element locator
Uncheck a toggle-button (checkbox/radio)

Selenium Commands - Part 8

T

type(locator, value)
Arguments:
• locator - an element locator
• value - the value to type
Sets the value of an input field, as though you typed it in.
Can also be used to set the value of combo boxes, check boxes, etc. In these cases, value should be the value of the option selected, not the visible text.


typeAndWait(locator, value)
Generated from type(locator, value)
Arguments:
• locator - an element locator
• value - the value to type
Sets the value of an input field, as though you typed it in.
Can also be used to set the value of combo boxes, check boxes, etc. In these cases, value should be the value of the option selected, not the visible text.


typeKeys(locator, value)
Arguments:
• locator - an element locator
• value - the value to type
Simulates keystroke events on the specified element, as though you typed the value key-by-key.
This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string; this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
Unlike the simple "type" command, which forces the specified value into the page directly, this command may or may not have any visible effect, even in cases where typing keys would normally have a visible effect. For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in the field.
In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to send the keystroke events corresponding to what you just typed.


typeKeysAndWait(locator, value)
Generated from typeKeys(locator, value)
Arguments:
• locator - an element locator
• value - the value to type
Simulates keystroke events on the specified element, as though you typed the value key-by-key.
This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string; this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
Unlike the simple "type" command, which forces the specified value into the page directly, this command may or may not have any visible effect, even in cases where typing keys would normally have a visible effect. For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in the field.
In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to send the keystroke events corresponding to what you just typed.