Tuesday 26 November 2013

When to use descriptive Programming in QTP

Descriptive programming in QTP is used in below scenarios.

  1. Whenever the objects in the applications change quite often.
  2. When it is not feasible to store the objects in OR. For example all links on the page
  3. When same object exists in the different pages/windows of the application.

There are 2 types of description programming.

  1. Static Descriptive programming
  2. Dynamic Descriptive programming

Static Descriptive programming Example - 

 Browser("index:=0").page("title:=Google").webedit("name:=q").set "xyz"

Dynamic Descriptive programming Example - 
'Find all edit boxes on google page using descriptive programming
Set descriptionObject = Description.Create()
descriptionObject("micclass").value = "webedit"
descriptionObject("outerhtml").value = ".*input.*"
descriptionObject("outerhtml").regularexpression = true

set col = Browser("index:=0").page("title:=Google").childobjects(descriptionObject)

print "Total edit boxes on the page"  & col.count

For i=0 to col.count-1
print col(i).getROProperty("outerhtml")

Next

You may also like below topics on descriptive programming in QTP.

  1. Using regular expressions in QTP.
  2. How to by pass OR in QTP.
  3. Description object in QTP.


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Error Handling in QTP

There are 2 ways in which we can handle errors in QTP.

  1. Err object.
  2. Recovery Scenarios.
Sample code to handle the error is given below

If err.number <> 0 Then
print err.description
else
print "there  was no error in above statement"
end if 


Whenever any error occurs in the script, We get the message window with detailed description of the error.

But when we are executing the scripts, we do not want this message box to appear to come as this will halt the execution of the script.

To prevent message box from appearing, we use below statement above the block of code.

On error resume next
----------
----------
more statements

With On error resume next in place, QTP script runs even though error exists in the code. We can capture those errors using Err object as stated earlier.

When you are debugging the scripts, you should not use On error resume next statement as it will suppress the errors and you will not be able to figure out the issue in your script.

You may also like below topics on error handling in QTP.

  1. On error resume next in QTP
  2. Err.Number in QTP

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to take a screenshot in QTP?

In QTP, when we execute the test cases, test cases may fail due to valid / invalid defects. They may also fail due to script issues or any other issues like network failure.

After the test execution ends, We only have the html reports or QTP results with us which does not give clear picture about the status of application. To solve this problem we can take the snapshot of the application when any test step fails.

Example - Below code will take the screen shot. You can insert this code anywhere you want to take the screen shot.

Window("xyz").CaptureBitmap "c:\screenshots\abc.png",True
'In above code we are storing the png image file to c drive location. Second parameter tells whether to overwrite existing file.

Thus you can use capturebitmap method of any object to take the screen shot.


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Sunday 24 November 2013

How to add standard checkpoints in QTP

Checkpoints are used to verify the property values with expected ones. If they match checkpoints pass else they fail.

You can add standard checkpoint by right clicking the statement and then selecting the insert standard checkpoint menu.

Sample checkpoint window is shown here..



Browser("Google").Page("Google").WebEdit("q").Set "salunke"

Browser("Google").Page("Google").WebEdit("q").Check CheckPoint("q_2")

Browser("Google").Page("Google").WebEdit("q").Output CheckPoint("q")

Browser("Google").Page("Google").WebButton("Google Search").Click

Results window showing the checkpoint status


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to create output value in QTP?

Output value is used to store the data generated by application while execution is going on for later use.
For example - Suppose after you place the order, order id is generated. So you can store this order id in output value so that you can use this value for later use ..say to fax the order

To add the output value you have right click on the statement after which you want to add output value.
Once you right click you will find the output value properties window like the one below.


You can check the property values that you want to store in the output value. You can also specify where you want to store the values (datatable or environment)

Browser("Google").Page("Google").WebEdit("q").Set "salunke"

Browser("Google").Page("Google").WebEdit("q").Output CheckPoint("q")

Browser("Google").Page("Google").WebButton("Google Search").Click




When You execute the script, in results you can find the output values.

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

What is the use of start transaction in QTP?

In QTP you will find one option called start/end transaction.

Transactions in qtp  are used to calculate the time required to perform the given operation
You can start the transaction using below syntax

Example on Transactions in QTP

Services.StartTransaction "transfer"
a = 2
b = a+2
'do some more opertions

Services.EndTransaction "transfer"

Once the transaction is complete, total time required to execute the transaction is logged in the QTP results automatically.




Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Dictionary Object in QTP with Example

Dictionary object is used to store the data in key-item pairs in qtp.

A Dictionary object is just like an associative array.
It stores the data in the form of key-item pairs.
Each key has some data item associated with it.
Key can be integer or string format.
Data item can be integer or string or array of variants. It may contain other dictionary itself.

Methods of Dictionary Object

Add -------> Adds new key-item pair in the dictionary object
Exists ----> returns true if the given key exists in the dictionary object
Items -----> returns the array containing all items in the dictionary object
Keys ------> returns the array containing all keys in the dictionary object
Remove ----> removes the key-item pair with given key from the dictionary object
RemoveAll -> removes all key-item pairs from the dictionary object

Properties of Dictionary Object

Count--------> returns the total number of keys in the dictionary object
Item---------> assigns or returns the item value with given key from the dictionary object
Key----------> sets the new key value for the given key
CompareMode -> assigns or returns the comparison mode for comparing string keys in a Dictionary object.

Example with dictionary object in QTP

'create new dictionary object
Set dictionaryObject = CreateObject("Scripting.Dictionary")

'add some key-item pairs
dictionaryObject.Add "1", "Sagar"  
dictionaryObject.Add "2", "Amol"
dictionaryObject.Add "3", "Ganesh"

'Display data in the dictionary
for each k in dictionaryObject.keys

print k & " - " & dictionaryObject.item(k)

next


'Remove the key-item pair with key = 1  from the dictionary object
dictionaryObject.Remove("1")

'Remove all key-item pairs from the dictionary object
dictionaryObject.RemoveAll

'Release the object
Set dictionaryObject = nothing

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Filesystemobject methods in QTP

Filesystemobject is used to access the computer's file system in QTP. You can read, edit, delete files using this object. You can also create/ delete folders using this object in QTP.

Most important methods of Filesystemobject

CopyFile Method ----------->copies file from one location to other with option to overwrite existing file
CopyFolder Method---------->copies folder and its contents from one location to other with option to overwrite existing folder
CreateFolder Method-------->creates a new folder. If the folder already exists, error occurs. So before creating a folder, check for its existance
CreateTextFile Method------>creates a new file and returns the textstream object with option to overwrite and format mode (Ascii or unicode)
DeleteFile Method---------->deletes the specified file. Error occurs if the given file does not exist
DeleteFolder Method-------->deletes the specified folder. Error occurs if the given folder does not exist
DriveExists Method--------->returns true if the given drive exists in the system else returns false
FileExists Method---------->returns true if the given file exists in the system else returns false
FolderExists Method-------->returns true if the given folder exists in the system else returns false
GetDrive Method------------>returns drive object for the given drive
GetFile Method------------->returns file object for the given file
GetFolder Method----------->returns folder object for the given folder
MoveFile Method------------>moves file from one location to another
MoveFolder Method---------->moves folder and it's contents from one location to another
OpenTextFile Method-------->opens the text file and returns the textstream object with option of iomode, create new file and format mode(ascii/unicode)

GetDriveName Method-------->gets the drive name for the given path
GetFileName Method--------->gets the file name (last component ) for the given path
GetExtensionName Method---->gets the extension for the given path like txt, mp3 etc
GetAbsolutePathName Method->gets the complete path for the given relative/absolute path
GetBaseName Method--------->gets the name of file (last component) excluding extension
GetParentFolderName Method->Gets the name of parent folder


Filesystemobject has only one property 
Drives Property------------>returns the collection of the drives objects in the system

Examples on filesystem object

   Set fso = CreateObject("Scripting.FileSystemObject")

   print fso.GetdriveName("c:\sagar\bl\metachara.txt")
   'output -  c:
   print fso.GetAbsolutePathName("c:\sagar\bl\metachara.txt")
   'output - C:\sagar\bl\metachara.txt
   print fso.GetExtensionName("c:\sagar\bl\metachara.txt")
   'output - txt
   print fso.GetBaseName("c:\sagar\bl\metachara.txt")
   'output - metachara
   print fso.GetFileName("c:\sagar\bl")
   'output - bl

You may also like below topics on file handling in QTP.

  1. Create a text file in QTP.
  2. Delete a folder in QTP
  3. Delete an Excel file in QTP
  4. Create a folder in QTP.
  5. Rename a file in QTP.
  6. Append contents to text file in QTP.
  7. Copy text file in QTP.
  8. Write data to text file in QTP.
  9. Check if file exists in QTP.
  10. Copy folder in QTP.
  11. Read a text file in QTP.
  12. Check if folder exists in QTP.
  13. Delete text file in QTP.

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Test Settings in QTP

Test settings is very important part of the QTP test. You can open the test settings from the file sub menu.
You will find below sections in test settings window.

1. Properties Settings:
In properties section you will find the location of the test and add-ins associated with the test.


2. Run Settings:
In run section you will find below settings.

  1. Data table iterations
  2. When error occurs - what to do
  3. Object Synchronization timeout




3. Resources Settings:
In resources section you will be able to see/edit the associated function libraries of the test.




4. Parameters Settings:
In parameters section you will specify the input and ouptu parameters.

You can access the parameters using script as mentioned below.

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
Set pDefColl = qtApp.Test.ParameterDefinitions
Set rtParams = pDefColl.GetParameters() ' Retrieve the Parameters collection defined for the test.
Set rtParam = rtParams.Item("sagar") ' Retrieve a specific parameter.
print rtParam.value



5. Environment Settings:
In Environment section you can view built - in and user defined global variables. You can also create new user defined variables here.




6. Web Settings:
In web section you can specify the browser navigation timeout.




7. Recovery Settings:
In recovery section you will be able to add and activate/deactivate  new recovery scenarios to the test.
You can also view the properties of the scenarios.


8. Local System Monitor Settings:
In this section you can monitor the various properties of the system like memory usage, cpu usage by given application during test execution.




You may also like below topics on test settings.

  1. How to associate library files in QTP.
  2. Folder structure in QTP
  3. Types of environment variables in QTP.
  4. How to get System Environment Variables.
  5. How to load ini file in QTP


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Recovery Scenario in QTP with Example

Recovery scenarios are used to handle the unexpected events that might occur while test execution is going on by QTP.

Please find below the steps that have to be followed to create the recovery scenario in QTP.

First of all You have to open the recovery scenario manager.  In resources menu you will find  recovery scenario manager option. Click on that and you will get to see below window.

Step1: Open Recovery  Scenario Manager.
Using recovery scenario manager you can create new recovery scenarios and store it in a file with .qrs extension.
One qrs file may contain multiple recovery scenarios.

To create new recovery scenario, click on the button circled with red color. It will open recovery scenario wizard.


Step 2: Open Recovery  Scenario Wizard.
Recovery scenario wizard shows the steps involved in creating the recovery scenario. Click on Next

Step 3: Select Trigger Event.
There are 4 types of the trigger events.
  1. Pop up window
  2. Object State
  3. Test Run Error
  4. Application Crash



Step 4: Specify the trigger Details.
In this step you have to specify more details about the trigger. For example if you selected pop up window in trigger event above, you will have to provide the title or text of the pop up as shown below.



Step 5: Recovery Operation.
After specifying the trigger event, you have to provide the recovery operation. There are 4 types of the recovery operations.
  1. Keyboard or mouse operation
  2. Close application process
  3. Function Call
  4. Restart Microsoft Windows





 Step 6: Post Recovery  Operation.
In Post Recovery You can tell what step should be executed after recovery is done by QTP.


 Step 7: Name  the Recovery  Scenario.
You have to give the name to recovery scenario in this step

 Step 8: Finishing the recovery scenario.
This is last step. You can add this scenario to current test in this step.



 Once you click finish recovery scenario manager window will be shown where you can save the qrs file.

Please note that to activate recovery scenario, you have to go to test settings.

You may also like below topics on Recovery Scenarios.
  1. How to Use Recovery Scenario Manager
  2. qrs file in QTP
  3. How to handle pop ups in QTP


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Thursday 21 November 2013

How to use Regular Expression Evaluator in QTP 11

In QTP 11,  Regular Expression Evaluator is a new tool added by HP. This helps us test the regular expressions on sample input strings. This is very useful tool.

To open Regular Expression Evaluator, you have to click on tools menu. There you will find option for Regular Expression Evaluator. Click on it.

  1. Once Regular Expression Evaluator is open, you can enter the Regular Expression inside the first edit box circled in red
  2. In large text box, you can enter sample text string that you want to test.
  3. Then you can click on the highlight button.
If the match is found, that is colored in yellow. It also shows you total number of matches found at the bottom of the Regular Expression Evaluator window.

Once you are sure that Regular Expression you have designed is working correct, you can use that in Object repository or in descriptive programming.

You may also like below topics on regular expressions in QTP.
  1. Regular Expressions in OR in QTP.
  2. Regular Expressions in descriptive programming in QTP.
  3. Regular expression evaluator in QTP.
  4. Meta characters in regular expressions.
  5. Case insensitive regular expressions in QTP.
  6. Regexp object in QTP.
  7. Global Property in Regular Expressions

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

What are the metacharacters (special characters ) in regular expressions in QTP?

Below is the list of all meta characters in QTP.


\ -  indicates that the next character would be a special character, a literal or a backreference

^  - Input String should be matched at the beginning.

$  - Input String should be matched at the end.

*  - Matches the preceding character zero or more times. It is same as {0,}.

+  -  Matches the preceding character one or more times.  It is same as {1,}.

?   - Matches the preceding character zero or one time.  It is same as {0,1}

{i} - Matches the previous character exactly i times.

{i,} - Matches the previous character at least i times and at most any time.

{i,j} -Matches the previous character at least i times and at the most j times.

.     -  Matches any single character except "\n".

(pattern) -  Matches pattern and captures the match that can be used in backreferences.
 p|q  -  Matches either p or q. Please note that p and q could be more complex regular expressions

[pqr]  - A character set. Matches any one of the character inside the brackets.

[^pqr]  - A negative character set. Matches any character not inside the brackets.

[p-z]   -  A range of characters. Matches any character in the specified range i.e p,q,r,....x,y,z.

[^p-z]  -  A negative range characters. Matches any character not in the specified range i.e. a,b,c...m,n,o 

\b      -  Matches the boundary of the word

\B      -  Matches middle part of the word.

\d      -  Matches a digit character. same as [0-9].

\D      -  Matches a nondigit character. same as  [^0-9].

\f , \n and \r     -  Matches a form-feed character, newline and carriage character.

\s    - Matches any white space character including space, tab, form-feed. Equivalent to [ \f\n\r\t\v].

\S      - Matches any non-white space character. Equivalent to [^ \f\n\r\t\v].

\t  , \v   - Matches a horizontal and  vertical tab character.

\w      - Matches alpha numeric character including underscore. Equivalent to '[A-Za-z0-9_]'.

\W      - Matches any non - alpha numeric character. Equivalent to '[^A-Za-z0-9_]'.

\number- A reference back to captured matches.

**********************************************************************************

**********************************************************************************

Some examples on regular expressions:
  1. To match the 10 digit mobile number ->  \d{10}
  2. To match email address  -> \w+@\w+\.\w+
You can use regular expression evaluator introduced in QTP 11 to test above regular expressions.

You may also like below topics on regular expressions in QTP.
  1. Regular Expressions in OR in QTP.
  2. Regular Expressions in descriptive programming in QTP.
  3. Regular expression evaluator in QTP.
  4. Meta characters in regular expressions.
  5. Case insensitive regular expressions in QTP.
  6. Regexp object in QTP.
  7. Global Property in Regular Expressions
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Wednesday 20 November 2013

How to use regular expressions in object repository (OR) in QTP?

Object repository stores the test object properties and their values. We can use regular expressions to set the values of the properties of the test object.

When we use the value as a regular expression, single test object in OR can be be used to find the multiple run time objects.

Example -


As shown in above image, we need to click on the button (circled with red) in front of the property value that you want to make as a regular expression. After you click that button, you will get below window

Then we need to enter the regular expression in the edit box and check the regular expression checkbox and click on Ok.

So now the test object will identify all the edit boxes that starts with q followed by any characters.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

What is the Difference between local and shared object repository (OR) in QTP?

Object repository is used to store the test object and its properties/values. There are 2 types of Object Repositories.
  1. Local
  2. Shared
Difference between local and shared OR

  1. Local OR is used by only one action in Test While Shared OR can be used by multiple actions and tests
  2. Local OR can be edited without OR manager While shared OR can be edited by using only OR manager
  3. We can not merge 2 local OR but we can merge 2 shared ORs using OR manager
  4. We can not compare 2 local OR but we can compare 2 shared ORs using OR manager
  5. We can associate/disassociate the shared OR to test at run time but Local OR is associated to test at anytime by default.
  6. Extension of the shared OR is .tsr while Local OR is .mtr
  7. When we export the Local OR, shared OR is created.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to use regular expression in descriptive programming in QTP?

As we know that there are 2 ways of descriptive programming.

  1. Static
  2. Dynamic
We can use  regular expression in both the ways as mentioned below. Please note that by default all the property values are considered as regular expressions by QTP.


' Regular Expressions in Static descriptive programming in QTP.

Browser("index:=0").page("title:=Google").Webedit("name:=q").set "sagar salunke"
Browser("creationtime:=0").page("title:=Google").Webbutton("name:=Google.*").Click

Please note that last statement uses regular expression to identify the button whose name starts with Google.
If your property value itself contains the special character then that should be escaped using \ character.

Example - Suppose you want to click on the link "+sagar".
Now this link contains the special character +. To click on this link, we can use below code
Browser("creationtime:=0").page("title:=Google").Link("innertext:=\+sagar").Click


' Regular Expressions in Dynamic descriptive programming in QTP.

Set descriptionObject = Description.Create()
descriptionObject("innertext").value = "+sgaar"
descriptionObject("innertext").RegularExpression = false

'Please note that we can specify whether the value is regular expression or not using RegularExpression property. By default it is true.

Browser("index:=0").page("title:=Google").Link(descriptionObject ).click

This is how we can use Regular Expressions in QTP

You may also like below topics on regular expressions in QTP.
  1. Regular Expressions in OR in QTP.
  2. Regular Expressions in descriptive programming in QTP.
  3. Regular expression evaluator in QTP.
  4. Meta characters in regular expressions.
  5. Case insensitive regular expressions in QTP.
  6. Regexp object in QTP.
  7. Global Property in Regular Expressions
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to create the case insensitive regular expressions in QTP?

Many times we need to find the string in given file and we are not worried about the upper case or lower case. In such scenarios we can create case insensitive regular expressions in QTP.

Case Sensitive Search
'**********************************************
'With IgnoreCase = false
'**********************************************
  Set regExpObject = New RegExp  
  search_string = "Arjun tendulkar is the son of sachin tendulkar"
  regExpObject.Pattern = "Tendulkar"

  regExpObject.IgnoreCase = false

  set matches = regExpObject.execute(search_string)

   print matches.count
'**********************************************
'output is 0
'**********************************************

Case Insensitive Search
'**********************************************
'With IgnoreCase = true
'**********************************************
  Set regExpObject = New RegExp  
  search_string = "Arjun tendulkar is the son of sachin tendulkar"
  regExpObject.Pattern = "Tendulkar"

  regExpObject.IgnoreCase = true

  set matches = regExpObject.execute(search_string)

   print matches.count
'**********************************************
'output is 1
'**********************************************


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Explain Global property of the RegExp object in QTP

Global property is used to tell how many matches should be found in the given string.

Examples to understand the global property are given below.

'**********************************************
'With global = false
'When we set the global property to false, we get only first match
'**********************************************
  Set regExpObject = New RegExp  
  search_string = "Arjun tendulkar is the son of sachin tendulkar"
  regExpObject.Pattern = "tendulkar"

  regExpObject.Global = false      

  set matches = regExpObject.execute(search_string)

   print matches.count

'**********************************************
'output is 1
'**********************************************



'**********************************************
'With global = true
'When we set the global property to true, we get all matches
'**********************************************
  Set regExpObject = New RegExp  
  search_string = "Arjun tendulkar is the son of sachin tendulkar"
  regExpObject.Pattern = "tendulkar"

  regExpObject.Global = true

  set matches = regExpObject.execute(search_string)

   print matches.count

'**********************************************
'output is 2
'**********************************************
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Explain RegExp Object in QTP

RegExp is a very important object in QTP that can be used to find the patterns in given string using regular expressions.

This object can be created using below syntax.
 Set regExpObject = New RegExp  

RegExp Object supports below properties.

Global Property     - a pattern should match all occurrences in string or just the first one
IgnoreCase Property - specifies if the search is case-sensitive or not
Pattern Property    - Sequence of literal characters and special characters (Meta Characters like *,?,+,\b,\d,\n etc)

RegExp Object supports below methods.

Test Method     - returns true if the pattern is found in the given string
Execute Method  - returns a Matches collection containing a Match object(having properties firstindex and value) for each match found in string.
Replace Method  - replaces the matched values in the given string by another value


Sample Example on Execute method.

'*******************************************************
 Set regExpObject = New RegExp  
  search_string = "MS dhoni is very lucky cricketer"
  regExpObject.Pattern = "lucky"

  regExpObject.Ignorecase = true
  regExpObject.Global = true
 
 Set matches  = regExpObject.execute(search_string)

 For each match in matches
print  match.firstIndex & " - " & match.value
 Next
'*******************************************************
In above example we are trying to find the pattern "lucky" in the given string "MS dhoni is very lucky cricketer". We are also printing the position where the match is found.

You may also like below topics on regular expressions in QTP.
  1. Regular Expressions in OR in QTP.
  2. Regular Expressions in descriptive programming in QTP.
  3. Regular expression evaluator in QTP.
  4. Meta characters in regular expressions.
  5. Case insensitive regular expressions in QTP.
  6. Regexp object in QTP.
  7. Global Property in Regular Expressions
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Tuesday 19 November 2013

Applications and Examples of Regular Expressions in QTP

Well - Before I jump to the applications of regular expressions, Let me explain what regular expressions are.

Definition :
A regular expression is a pattern of characters(meta characters and special characters).

General Applications of Regular Expressions :
Where are regular expressions used.
  1. Pattern Matching in Strings
  2. To find the occurrences of one string/pattern in given string.
  3. To replace the patterns with another string in a given text
All programming languages support the use of regular expressions. 

Regular Expressions in QTP :
We can use regular expressions in qtp in many ways as mentioned below.

  1. In QTP, object repository is used to store the object's properties and values. We can use regular expressions to specify the object property value.This helps us using same test object to identify multiple run time objects in the application. 
  2. We can also use regular expressions in descriptive programming. 


QTP examples on Regular Expressions:  
As I said earlier We use regular expressions to check if the given string matches the specified pattern.
For example - Consider a scenario where you have to validate that the given string should be a valid email address.

So list of valid email addresses are - reply2sagar@gmail.com, ayx@jjjj.in etc
Some of the invalid email addresses are - kjkjj@fdff, @dfdf.in etc

With the help of regular expression, you can easily validate the email address.

Syntax of Regular Expression in QTP:
In any QTP program related to regular expression, you will follow below steps.
  1. Create a regular expression object (RegExp)
  2. Define the pattern using RegExp object's pattern property.
  3. Use test method to check whether the given string matches with the pattern specified in step 2.
'Create the regular expression object
Set myRegEx = New RegExp 

'Specify the pattern (Regular Expression)
myRegEx.Pattern = "[a-z0-9]+@[a-z]+\.[a-z]+"

'Specify whether the matching is to be done with case sensitivity on or off.
myRegEx.IgnoreCase = True

'Use Test method to see if the given string is matching with the pattern
isMatched = myRegEx.Test("reply2sagar@gmail.com")

Variable isMatched will be true if the string "reply2sagar@gmail.com" matches with the given pattern 
"[a-z0-9]+@[a-z]+\.[a-z]+"

Sunday 13 October 2013

Software testing interview questions for 1/2/3 years of experience

 Welcome  - On this page, you will find all advanced software testing interview questions for experienced candidates (1/2/3/4 years).

All the questions listed below are frequently asked in software companies like TCS, Cognizant, Infosys, HCL, IBM, Wipro, Syntel, Capgemini, Amdocs.
 

1. What is fault masking?
Fault masking means presence of one defect will hide the presence of another defect in the system.

2. What is exploratory testing?
Exploratory testing is a type of experience based testing.In exploratory testing, we test the software starting with basic functionalities and then
using the information about the system, we try to test more functions of the system. In short we explore the system as we move ahead with the testing.

3. How do we prepare test plan?
IEEE 829 specifies what attributes are there in test plan.

4. What are the different stakeholders in testing process?
Every testing project has below stakeholders.
Developers
Testers
End Users
System Owners
QA and Development Managers

5. What is configuration management wrt software testing?
Configuration management is used to manage the changes done to the test artifacts.
Every testartifact is stored in the configuration management software like SVN.  We can access all the versions of the same document.
We can also track who made what changes in which document and when.

6. What are different software testing metrics?
Software testing has below metrics.
Code Coverage
Cyclomatic Complexity
etc.


7. How to do test estimations?
Test estimations are carried out to give better picture of how much human effort will require to test the software and the cost of the project.
Based upon the scope of the testing project, we estimate the effort required to test the system.

8. What is orthogonal testing? Explain with example.
Orthogonal testing is used to test the application with only few test input values from given set of inputs.
Exhaustive testing with all permutation and combinations of input values is not possible. So orthogonal testing helps us to reduce the test input domain values.

9. What is error / mistake?
Error is a human action that produces incorrect result.

10. What is defect(bug/fault)?
A flaw in the system that can cause the system to fail to perform its required function.
If the code containing defect is executed, software failure occurs.
Cost of finding and fixing the defect increases over time so you must try to find out the defects as early as possible in SDLC.

11. What is exhaustive testing?
It is a type of testing in which we try to test the software with all possible input values and preconditions.

12. What are different software testing pronciples?

There are few testing principles that every tester must know as mentioned below.
Testing shows that there are defects but it does not prove that there are no defect. This means that even after we test the software, we can have defects still present in the system
Exhaustive testing is not possible. Many systems are very complex. So testing such systems with all possible input values is not possible.
Testing should be started as early as possible because the cost of finding and fixing the defect increases over time.
Small number of modules contain most of the defects in the system. So we must focus on those error prone modules while testing the system
Pesticide paradox - If same tests are run again and again, they will no longer find any defects in the system. So you must always try to change the test cases, input values so that you will be able to find new uncovered defects.
Software testing is context dependant. Every system should be tested in different way as Some systems are life critical while some are very simple systems. So the objectives and priorities of the testing are different for every system.
Absence of error fallacy : - If there are no errors in the system, it does not mean that system is good  if end user is not able to use the system easily and it meets its requirements.

13. What is COTS?
COTS stands for the commercial off the shelf software. This kind of software is developed for large number of customers is delivered to many customers across the world.
For example - chrome browser.

14. What are the different software testing models?
WaterFall Model.
Increamental Development Model - RAD, RUP, Agile (extreme programing)
V-Model

15. What are software testing levels?

1. Unit testing              - done by developers
2.Component Testing    - done by developers
2. Integration testing     - stubs, drivers
3. System testing         - functional , non-functional
4. User Acceptance testing - Alpha and Beta testing

16. What are software testing methods?
There are 2 methods of software testing.

1. Static - review, walkthrough, inspection, data flow, control flow
2. Dynamic testing - white box(structure based/glass box), black box (Specification based), expereince based

Below is the list of white box testing methods.
1. Statement coverage
2. Decision Coverage
3. Condition Coverage

Below is the list of black box testing methods.
1. Equivalance partitioning
2. Boundry Value Analysis
3. Decision Tables
4. State Transition Diagrams
5. Use Case Testing  - ATM Example.

Below is the list of experience based methods.
1. Error Guessing
2. Exploratory Testing


17. Explain below IEEE 829 specifications - Test design, Test case, Test Plan, Test log, Incident Report , Defect Report , Test summary report.
IEEE 829 is a standard for creating test artifacts. Each test document has specific attributes.
For example - Test Plan has below parameters/attributes.


  • Test Plan Identifier
  • Introduction
  • Test Items
  • Features to Test
  • Features not to Test
  • Approach
  • Item pass/fail criteria
  • Suspension/Resumption Criteria
  • Test Deliverables
  • Test Tasks
  • Environment Needs
  • Responsibilities
  • Staffing and training needs
  • Schedule
  • Risks
  • Approvals


18. What is probe effect?
Effect on the system when it is being measured.

19. What are different tools that can be used in testing process?
We can use software tools in almost every phase of software testing lifecycle. Quality center is the one which is very useful.
We can have requirements management tool that helps in recording of requirements and requirements traceability.
Defect management tool is used to record and track incidents and defects.
Configuration management tools are used to control the changes in  test artifacts.
Review tools helpus in test review process of documents, codes.
Test execution tools (QTP, Selenium) are used to record  and playback the automated operation in application.
Dynamic analysis tools are used to get the runtime information of the state of the software code which can be used to identify the
unassigned pointers, memory allocation, memory leaks.
Performance testing tools (LoadRunner, Jmeter) are used to measure how the system behaves when there are more users actively using the system or there is large volume of data.
Load testing - More users, More transactions
Volume testing - Large volume of data
Stress Testing - testing the system beyond its specified hardware/software requirements.
Debugging tools(Microsoft debugger) are used to find and remove the cause of the failure in the system.

20. Explain different software testing metrics like defect density, cyclomatic complexity, code coverage, statement coverage, decision coverage etc.

code coverage = no of coverage items exercised/total number of coverage items * 100
code coverage finds out which part of the code has been executed by the test suite.
Statement coverage = no of statements exercised/ total number of statements * 100
Decision coverage = no of decision outcomes exercised / total number of decision outcomes * 100
Cyclomatic complexity = no of branches in the code + 1

21. Explain defect/incident lifecycle.
Whenever new incident occurs in the system, we create a new incident to track it.
Each incident follows typical lifecycle.
When it is confirmed that defect is a valid then we assign it to the developer and it's status becomes assigned.
Then developer will fix the issue and status of the incident will be marked as fixed.
Then again testers will retest the system to verify that the defect is really removed from the system.
If defect is removed from the system, status of that defect/incident is marked as closed otherwise status of the defect becomes reopened.


22. What is test condition?
Test condition is an item in the system that could be verified by one or more test cases.

23. What is test case?
A set of input values, execution preconditions, expected results, execution postcondition is called as a test case.

24. What is test Oracle?
Test oracle is a source to determine the expected results to compare with actual result.

You can visit QTP Master page to learn QTP.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Software testing interview questions and answers for freshers

When you appear for the QTP interview or selenium interview, you may be asked some common software testing interview questions.

In below paragraph, you will find frequently asked software testing interview questions and their answers asked in different software companies like TCS, cognizant(cts), Tech Mahindra, Infosys, Wipro, TCS, Syntel, Capgemini, Cybage, Amdocs, IBM etc.

1.What is software testing?
Software testing is the process of validating and verifying the software product.
Objective of the software testing is to check that software under test meets the requirements in System Requirements Specification (SRS) and the
expectations of the end users.
Software testing gives the information about the quality of the software.
There are different software testing lifecycle models based upon the SDLC like waterfall, agile, extreme, incremental etc

2. What are software testing types?

Every testing activity that Test team does will have a specific objective. Based upon this objective we can categorize the testing as mentioned below.

Installation testing     - Testing done to check that software system can be installed on the desired platform seamlessly.
Compatibility testing  - Testing which checks that system is compatible with different hardware and software products.
Smoke testing           - Most critical test cases are selected and run to check that important modules of the system work or not.
Sanity Testing           - Testing few test cases from every module to determine if it is ok to proceed with further testing.
Regression testing     - Testing the system to verify that the fixes done by the developers are working as expected and there are no new defectd induced
Acceptance testing   - Testing done from end user perspective
Alpha testing            - Alpha testing is actual testing by developers/potential users/customers/ an independent test team at the developers' site
Beta testing             - Beta testing is done by acutal customers at their own location or site. Developers are not involved.
Functional Testing    - We test the feature or functionality of the system
Non-functional testing - We test scalability, performance and security of the system.
Destructive testing       -Testing used to cause the system to fail. It checks the robustness of the system when invalid inputs are given.
Software performance testing -Testing used to check the system stability and scalability under many  transactions with large volume of data
Usability testing          - Testing is used to test the ease of use from end user perspective.
Accessibility testing    - Testing to check if users with some disabilities can access the system easily
Security testing          -  Testing used to test how secure the system is. We also try to find out any vulnarabilities in the system.
Internationalization and localization - Testing to check if system is working as expected in different geographic settings.




3. Explain software testing lifecycle?

1.Requirements analysis
2.Test planning: Test strategy, test plan, testbed creation.
3.Test design and development: Test scenarios, test cases, test datasets and automated test scripts are created in this phase.
4.Test execution: Manual and automated execution of test cases is carried out.
5.Bug logging: Defects are logged.Development team decides which defects should be fixed, rejected etc After defects are fixed, testers again try to retest the defect and again reopen the defect if it is not really fixed.
6.Test Reporting :Test metrics and summary reports are generated.
7.Test Closure :Testing ends when the exit criteria is met and learnings from testing could be used as a reference for new software projects.

4. What is the difference between manual testing and automation testing?
Manual testing involves testing of the software without any automation software. Human effort is required to execute the test cases.
In automation testing we use software tools like QTP, selenium to automate the test execution process.
In manual testing we need manual efforts while in automation testing initial efforts are required to develop the automation script. In regression execution, we can use
automation testing to execute the test cases day and night without manual intervention.

5. What is automation testing?

Automation testing is nothing but use of softwares ( like QTP, Selenium)  to test the application under test.
Automation testing helps minimise the manual effort. It saves efforts and cost to execute the test cases.
Advantages of automation testing-
It helps in reduction of testing execution time
Human Efforts are also saved
It is accurate in calculating the output values.
Overall it helps in reduction of cost of testing.

6. What is black box testing ?
Black box testing is also called as specification based testing. Black box testing is a testing in which we don't know internal details like code structure of the software.
We give the input to the system and verify the output produced by system. We don't worry how the system calculates the output as long as system is giving correct output.
Here is the list of black box testing methods.
Equivalance partitioning
Boundry Value Analysis
State transition Diagrams
Decision Tables
Orthogonal Array Testing
Use Case Testing

7. What is white box testing?
Unlike black box testing, in white box testing we know the internal details like code, algorithms of the software.
We try to test the internal structure is working as expected. This is generally done by the developers of the software.
In white box testing, we find out below test metrics.

code coverage = no of coverage items exercised/total number of coverage items * 100
code coverage finds out which part of the code has been executed by the test suite.
Statement coverage = no of statements exercised/ total number of statements * 100
Decision coverage = no of decision outcomes exercised / total number of decision outcomes * 100
Cyclomatic complexity = no of branches in the code + 1

8. What is grey box testing?

Grey box testing is a combination of black box testing and white box testing.

9. What is the difference between static and dynamic testing?
In static testing, We try to find the defect in the system without executing the software. For example, review of the code by peers, Finding the cyclomatic complexity
of the code.Static testing involves code review, walkthrough, inspection, data flow, control flow of the system

In dynamic testing, we execute the software. We provide some input and verify the output. So we can find the run time errors in dynamic testing
Dynamic testing involves white box(structure based/glass box), black box (Specification based), expereince based testing.


10. Explain unit testing.
Unit testing is done by the developers of the software. Testers are not involved in unit testing. Unit testing is the method in which smallest part of the system are tested.
Usually smallest part of the system is function or procedure or class methods in object oriented programming.
Stubs may be created for the unit testing the code.

Almost all programming languages have unit testing frameworks that are used by the developers to test thier code.
For example - Junit is a unit testing framework in Java.


11. Explain Integration testing.
Integration testing is generally done after unit testing. After the small modules have been tested, they are grouped together to form the system.
Integration testing is used to verify that different modules have been integrated seamlessly and there is no defect while integrating the modules/components.
The objective of the integration testing is that all the modules/components are interacting with each other correctly.
Types of integration testing are :-
1. Top-down     -> Top level integrated modules are grouped together and sub-system is tested.
2. Bottom-up    -> Bottom level integrated modules are grouped together first and sub-system is tested.
3. Big Bang      -> In Big Bang approach, all modules are integrated together and then testing is done.


12. Explain System testing.
System testing is done after integration testing. This is used to verify that system works as expected and meets the expected requirements.
System testing is a black box testing.

Here is the list of types of system testing.
Functional Testing
Performance testing - Load testing, Volume testing, Stress testing, Scalability testing
Compatibility testing
Security testing
Sanity testing and Smoke testing
Exploratory testing
Ad hoc testing
Regression testing
Installation testing
Maintenance testing
Recovery testing.
Accessibility testing
Usability testing


13. What is the difference between functional testing and non-functional testing?
Functional testing means testing the software to verify that software adheres to the functional requirements.
While non-function testing involves other aspects of the software like accessibility, usability and performance testing.

14. What is security testing?
Security testing means testing the software from security perspective. It verifies that the system complies to the security standards and
there are no loopholes in the system.

15. Explain usability testing.
Usablity testing is used to test ease of use of the software.

16. Explain performance testing.
Performace testing includes load testing, volume testing and stress testing.

17. Explain exhaustive testing with example.
Exhaustive testing means testing the software with all possible permutation and combination of the input.

18. What are different software testing tools in market?
We can have different software as mentioned below to test the softwares.
QC
QTP
bugzilla
Test Track
Test Complete
Test Studio
Jira
Loadrunner
Winrunner

19. What are the automation testing tools in the market?
Here is the list of automation testing tools in the market.
QTP
Selenium
Test Complete


20. What is Quality Center and what are the different modules in it?
Quality center is a test management software from HP. It involves below modules.
Requirements
Test Plan
Test Lab
Defects

21. What is selenium?
Selenium is an open source web application testing tool. Selenium provides APIs in different languages like .net, java, python, perl, ruby etc.
We can test websites on different web browsers like Internet explorer, firefox, chrome, safari using selenium.

22. What is the differnece between selenium and QTP?
QTP is functional automation testing tool that can be used to test applications developed in variuos platforms like .net, Java, peoplesoft etc.
It is not a open source software.It is the most popular automation testing tool in the industry as of now.

Selenium is an open source web application testing tool. Selenium provides APIs in different languages like .net, java, python, perl, ruby etc.
We can test websites on different web browsers like Internet explorer, firefox, chrome, safari using selenium.



23. What are the different software testing artifacts?
Here is the list of common testing artifacts.
Test cases
Test execution report
Defect report
Incident report
Test Plan.
Test Summary Reports

24. Explain software defect and software failure.
Software defect is an unwanted condition in the software which when executed may result in the system failure.

25. What is the difference between test case and test script?
Test case is detailed stepwise description of how we can verify the requirement manually.
Test script is the automated version of manual test case.

26. What do you mean by dynamic program analysis?
Dynamic programming analysis means testing the program while executing it.Dynamic program analysis helps in understanding time and space complexity of the program. We can also find memory leaks in the program while executing the program.

27. What is Pair testing?
Pair testing is a testing type in which 2 team members work together to test the application.

28. What is high priority defect?
High priority defect is the defect which must be fixed as soon as possible.

29. What is high severity defect?
High severity defect is the defect which can cause huge loss if it is available in the system.

30. What is the difference between re-testing and regression testing?
Re-testing is used to check that defect is really removed after developers fixed it.
While regression testing is used to check that post-modification of software, no new defects were induced in the system.

31. What is boundry value analysis?
Developers tend to make mistakes while designing the code to check boundry conditions.
Boundry value analysis can be used to find the defects found at the boundry values.

Example - Consider education grading system.
If student scores more than 75%, his grade is distinction while if he scores between 60% and 75%, his grade is first class.
In this scenario, we test the software using boundry values like 59,60,61,74,75,76 to check that software provides correct output.

32. When should we stop testing?
Below is the list of factors that help us determine when we should stop testing.
For every testing project, we have the exit criteria.
We execute the all the test cases that test all requirements of the system.
We try to find the the defects in the system.
When we have a confidence about the quality of the software, then we may stop the testing.
All stakeholders in the testing project must give green signal to stop the testing.
We have also time and budget constraints so we focus on the most important functionalities of the software.

33. What is test coverage?
Testing is done to check that all our functionalities are working as expected or not.
Test coverage is the metric that gives us idea about how many functionalities have been tested
Test coverage can have below types.
Code Coverage
Decision Coverage
Functionality Coverage

************************************************************************
Please note that if you are staying in USA, UK or Australia, and searching for a testing job there, above testing questions and answers will help you crack the interview.

You can visit QTP Master page to learn QTP.
Please give your inputs, suggestions, feedback to Us about above Software testing topic. We value your thoughts.If you want to ask any question, you can comment it below.

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.