Skip to main content


Showing posts from 2012

Read, Write Excel - QTP, VbScript

Lot of members are facing some errors whenever trying to connect and read/write values from excel or other databases. Here is some code snippet which will easy the task for you...

To Get Data:
Function GetData(strFilePath, strSQL)
 Dim objConn, objRecord, strConnectionString
 Set objConn = CreateObject("ADODB.Connection")
 Set objRecord = CreateObject("ADODB.RecordSet")

 strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFilePath & ";Excel 12.0;HDR=YES;READONLY=1;IMEX=1;"

 objConn.Open strConnectionString
 objRecord.Open strSQL, objConn
 msgbox objRecord(0).Value
End Function

Points to take care:
1. Always use readonly=1 to force read-only mode while reading.
2.Use IMEX value based on your requirement.
IMEX=1 - It will convert all data types to text and return.
IMEX=2 - It will return the data as it is.

To Write Data:
Function UpdateData(strFilePath, strSQL)
 Dim objConn, strConnectionString
 Set objConn = CreateObjec…

QTP - Get multi line data from Excel Cell

Today I am going to write a simple topic on excel and it seems very simple but lot of automation testers in need of this topic. Say I want to have multiple data on a single cell(using ALT+ENTER). This will solve the purpose as well as maintenance easy. 
Ok, How to get that data from excel and separate the data which was enterted using ALT+ENTER.
Just get the cell data and replace the string for vbLF with "" (Empty String) and you can pass your data.
Normally new line indicates vbCRLF (Chr(13) + Chr(10)) but in excel new line char is Char(10) i.e. only vbLF not vbCR or vbCRLF.

Hope this will help you guys !!!

QTP - Memory Usage and Others

Lot of guys will face app hanging problem while script execution in QTP. You can always use QTP provided SystemMonitor API to know memory usage by application an you can decide your control mechanisms.

SystemMonitor.GetValue("YourApp.exe","Memory Usage (in MB)")

In the same way, you can get processor usage, Os details, etc..
If this will give you exact thing, always you can use WMI to get every system information you need.

QTP - Object Identification Types / Ways

In QTP, we can use lot of ways to identify an object. Most of the QTP Test Developers are always using streamlined and static approaches and if object is not identifiable using those approaches, just leaving then as not identifiable.
We can try using below ways of handling objects for our purpose before saying NO !!!

1. Store the objects in OR
If you are comfortable on using OR and suitable for your project with your designed framework, you can go ahead with OR.
a. Add the object in OR, then see what are the properties will make QTP to identify this object uniquely. 
b. Remove unwanted properties
c. Add unique and required properties
d. Assign regular expressions for the required properties which have dynamic values in full or part.Make use of Reg Exp Evaluator to set the RegExp correctly.
e. Assign a human understandable, easily classifiable logical name for the object based on type of object, application module or screen, etc.

2. Use Descriptive Programming
Here you can use 2 types of DP.
1. I…

QTP - Common error messages

Always I am seeing  many of my friends asking for help if any error occurs while running script in QTP without googling for help. How much troubleshooting you guys are doing will directly reflect your knowledge on the tool. I agree, no one knows each and every error occurs in the software. But we can improve our knowledge by googling and doing workarounds...
Whenever the question "How much level you know QTP?" arrows me, always I am comfortable with the answer "below 10%". But after answered, my mind will have an inner thought like, What are the things I have to learn to fulfill the answer I have told because I never used lot of features in QTP.

Here I am listing out some of the errors, situations and what might be the original issue things etc. I hope this will give you some ideas to improve your debug ability and to solve your errors. Kindly correct me If I am wrong in any point.

Type mismatch:
- Mostly doing operations with different data types without doing type co…

Common QTP Topics/Questions

Here I am listing out some common QTP topics those are concentrated on most QTP interviews. Hope this will help lot of QTP beginners.

1. Why we go for automation?
2. What is Action? What are the types?
3. What is function? What is Sub? Diff between these two?
4. What is OR? Types of OR?
5. Which kind of OR is best?
6. What is TO? What is RO?
7. How QTP identifies object in UI and does the operations?
8. What are types of properties for a object? Mandatory, Assistive, Ordinal Identifiers.
9. What is smart Identification?
10.What is Synchronization? What are the synchronization methods available?
11.How you generated your results?
12.How you will email the results automatically after execution?
13.What is framework? Have you worked/designed a framework?
14.VBScript - String functions, Array, FileSystemObject, DictionaryObject
15.Connecting Excel and fetching data?
16.Connecting database and fetching data?
17.What kind of applications you have automated?
18.What kind of controls you automated? Native Cont…

Agile Model - SCRUM Process Overview

Lot of testers have interest to know about,
1. What is agile model?
2. What is the advantage of it over other models?

Agile - Simply we can say "On demand, more monitored and controlled testing"
Agile model have benefits like,
1. Easy adoption of requirement changes at any stage.
2. Piece of working product will be arrived very early in life cycle.
3. More monitoring on team so every team members will be in same path and goal.

SCRUM is one of a process of agile methodology. SCRUM involves below terms,
1. Sprint
2. Scrum master
3. User Stories
4. Work Items
5. Sprint Back Logs
6. Sprint retrospective item, etc.

Sprint - Sprint is nothing but the scrum period. i.e. The no of days for between each release like 30 days, 15 days. This is mainly based on customer requirement. If your every sprint consists 30 days, then every 30 days there will be a release. Sometimes release will not be there based on customer request.

Scrum Master - The person responsible to assign the tasks to team members and …

What is Framework?

Today, I am going to discuss about framework due to request of my friend Anand.

Lot of QTP guys know the information on How to Create Test, How to identify Complex objects, How to generate results and etc. But still somebody have doubts like
What is Framework?
Why we need Framework?
What's the purpose of it?
How to design framework?
Is that required lot of coding knowledge?, etc.

Let's consider a case. We have 100 test scenarios to automate. Each test scenario have around 100 test cases. Here you will do the following....
1. Create Test Scripts for each case by creating separate actions.
2. Each test case script i.e. each action will have associated resources. - Object Repository, Function Library and Recovery Scenario files.
1. You will have own driver script.
2. This will call each action one by one.
1. If any UI changes happened, you need to find the particular OR file to update the same.
2. You need to maintain lot of OR files which is a tough task.
3. If an…

Download File - VBScript function

Here is the function to download any file over internet using XMLHTTP COM objects in VBScript. 

Function Download(sFileURL, sLocation) 'create xmlhttp object Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP") 'get the remote file"GET", sFileURL, false 'send the request   objXMLHTTP.send() 'wait until the data has downloaded successfully dountil objXMLHTTP.Status = 200 :  wscript.sleep(1000) :  loop 'if the data has downloaded sucessfully If objXMLHTTP.Status = 200Then 'create binary stream object Set objADOStream = CreateObject("ADODB.Stream")     objADOStream.Open 'adTypeBinary     objADOStream.Type = 1     objADOStream.Write objXMLHTTP.ResponseBody 'Set the stream position to the start     objADOStream.Position = 0

ExecuteGlobal in VBScript

Most of guys will face this problem like,
- Having a class in a .vbs file say class1.vbs
- In another .vbs file, trying to create object for that class
Here it will say class is undefined because your class should be in global namespace so that your second script should know. To achieve this, use ExecuteGlobal command in VBScript.
Here I am putting sample function to include your class or other .vbs files which you are going to refer.
'To include a file which are referenced here. Sub Include(file) Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(file, 1)   str = f.ReadAll   f.Close ExecuteGlobal str EndSub 'Just call this function like this in your scripts Call Include("C:\class1.vbs") 'Then try to create object for the above class Dim obj Set obj = New Class1 'continue... Hope this give you ideas !!!

Start learning VBScript or JavaScript

Lot of guys who are interested to move to automation testing from manual have dilemmas on how to start learning the scripting language, which one I have to install, where to study, etc.
For those who are covered under the above case, this article is for you.
Both VBScript and JavaScript will run on windows based script host. So follow the simple steps to learn.

1. Just create a text file in your system and save it as .vbs(VBScript)or .js(JavaScript)extension.
2. Open the .vbs or .js file using notepad or other your favorite notepad editor like wordpad, notepad++, etc.
3. Just do your code and save.
4. Just double-click the .vbs or .js file. It will execute and give you results.
5. For your understanding like what value it returns, use msgbox which will show the value in dialog while executing for VBScript. For JavaScript, just create an object for "WScript.Shell" and use Popup.
6. If errors in your code, the it will give you error dialog by specifying error line and other info.
For t…

VBScript Dictionary Object vs JavaScript Object

In test automation world, always we have situations to return more than one value from a function call. For this we have some simple ways but yet always we searching for better ways. Here I am listing some ways we can 
1. Array
We have simple array concept in all languages but this not effective while retrieving values for a particular field because array is related to index. We can't know at which index which value is there. We have to implement our own methods to find them.
2. Class and Objects
This is an another effective method but the user need some information about classes and objects. You can create a class, then class variables for all fields you are going to return values. So just create an instance for this class i.e. object and assign the values for all properties associated with this object and return this object.
Here you can directly get your particular field value by passing the field name. No concept of indexes like array. So simple to access a value and assig…