Wednesday, January 18, 2012

How to close any application without using the object ?

SystemUtil.CloseProcessbyName <.exe name of the application>

What are the options to write the QTP Sccript without using the Object Repository ?

1.Using Description object and using that object in the place of logical name in the script.
2.Writing object property and value pairs directly in the place of logical name in the script.

Where can we put the Regular expressions in the QTP Script ?

1.Property Value in Object Repository
2.Property Value in Description object.
3.Property Value in Property,Value pair which is in the logical name of the script.

How many ways we can add an object to Object Repository ?

1.New Test Object from Object Repository
2.Add Test Object from Object Repository
3.Add Test Object option from Active Screen

How to fetch unmatching records from two SQL tables?

Table1
Id Name
1 Prashant
2 Ravi
3 Gaurav
5 Naween
7 Sachin

Table2
Id Name
1 Prashant
2 Ravi
4 Alok
6 Raja

The output I want is
Id Name
3 Gaurav
4 Alok
5 Naween
6 Raja
7 Sachin


select a.Id, a.Name from Table1 a left outer join Table2 b on a.Name = b.Name where b.Id is null
UNION ALL
select a.Id, a.Name from Table2 a left outer join Table1 b on a.Name = b.Name where b.Id is null

how to use ADO to read and write data in Excel workbooks?

How to Use a closed workbook as a database (DAO) using VBA in Microsoft Excel ?



Dim db As DAO.Database
Dim rs As DAO.Recordset

strPath = "D:\Gopi\Automation Stuff\"
intColARws = Worksheets(1).UsedRange.Rows.Count
intColBRws = Worksheets(2).UsedRange.Rows.Count
gSheet1 = "[Sheet1$A1:A" & intColARws & "]"
gSheet2 = "[Sheet2$A1:A" & intColBRws & "]"
Set db = OpenDatabase(strPath & "CompareExcel.xlsm", False, True, "Excel 8.0;") ' read

If db Is Nothing Then
MsgBox "Can't find the file!", vbExclamation, ThisWorkbook.Name
Exit Sub
End If

Set rsLeft = db.OpenRecordset("SELECT " & gSheet1 & ".ColA" & " FROM " & gSheet1 & " left outer join " & gSheet2 & " on " & gSheet1 & ".ColA <> " & gSheet2 & ".ColB" & " where " & gSheet2 & ".ColB is null")
i = 1
While Not (rsLeft.EOF)
'MsgBox rs.Fields("ColA")
Worksheets(3).Range("A" & i).Value = rsLeft.Fields("ColA")
rsLeft.MoveNext
i = i + 1
Wend

Tuesday, January 17, 2012

Coding standards to be followed in the QTP ?

1.Automation Engineer needs to add a section on top of every action/function which describes the action/function name,action/function description
2.Option Explicit statement must be included in the begining of every script/action.
3.The variables used in the action/function should be in the following way:
intEmpNo for integer type of variables
strEmpName for string type of variables
arrintEmpNames for integer type of array variables.
objQTP for object type of variables.
4.Exceptions should be handled by Code
5.Clear the objects at the end of the action/function
6.Logical names in the object repository should follow the naming convention like:
win_FlightReservation for windows
dlg_Flights for dialogs
txt_AgentName for text boxes/edit boxes.
page_Google for web pages.
RdBtn_Business for Radiob buttons.
ChkBx_First for Check boxes.
lst_FromCity for list /combo boxes.
wt_EmpDetails for WebTable.
lnk_Settings for

What makes a good Test Engineer ?

The TEst Engineer who has good knowledge on the application and domain of the application will be able to write more test scenarios/testcases .