Wednesday, May 25, 2011

QTP-File Extensions

Hi Folks,

Following are type of file extensions used in QTP.
  1. function library files = .vbs, .qfl and .txt
  2. local object repository file = .mtr
  3. shared object repository file = .tsr
  4. recovery scenory file = .qrs
  5. Default.cfg :- "Microsoft Office Outlook Configuration File"
  6. Default.xls :- "This is the copy of the internal datatable which is there by default. 1 sheet is Global, other sheets are as per the Action names"
  7. Login.usr :- "It is a kind of default constant file where all the inbuilt vaialbles are assigned some values or otherwise"
  8. Script.mts :- "This is just the scripts as per each action. Whatever you write in each action will be saved here"
  9. thick_usr.dat :- "It is a kind of default constant file where all the inbuilt vaialbles are assigned some values or otherwise"
  10. thin_usr.dat :- "It is a kind of default constant file where all the inbuilt vaialbles are assigned some values or otherwise. It consists of less no. is variables than thick_usr.dat"

Wednesday, May 18, 2011

QTP-How to use Parameter using QC

How to use Parameter in QTP

To use parameter in QTP, first we need to declare it in QC under parameter tab. If you want to define Input parameter then, you have to define it in input section. If you want to define output parameter then you have to define it in output section. Parameter name should be same in QC and QTP script.

Steps
  1. Create first component
  2. Define input and output parameter in QC
  3. Declare parameter value in QTP script
  4. Assign value for input parameter in QTP, example parameter(“SearchStr”)=”string for search value”
  5. Use the input parameter in control
  6. Use run time value and assign it to output parameter for use in QTP, example parameter(“outurl”)=”www.google.com”
  7. Now, make second component
  8. Use first component’s output parameter as input value in second parameter.
  9. Follow same steps as mentioned in first component.
  10. Now to run the QC and use parameter create test case in test plan module.
  11. Pull the first and second component in test case.
  12. Give input value in first component for run.
  13. Check use output value of previous component checkbox in second component.
  14. Integrate test case with test lab.
  15. Run the test case from QC.
  16. It will take input search string from first component and output value of first component is used as input of second component and execute whole test combine.
 Sample script1

Dim browsernm,pagenm
browsernm="Google"
pagenm="Google"
URL=http://www.google.com/
SystemUtil.Run "iexplore.exe",URL
reporter.ReportEvent micPass,"IEopen","Google open"

‘code for debug and error handling purpose
On Error Resume Next
Err.Clear
Dim testset, n
Set testset = QCUtil.CurrentTestSet
n = testset.name
If Err.Number <> 0 Then
Errr.Clear
End If

'Debug Declaration

If n = "" Then
Parameter("Searchstr")="Parameter Test in QTP"
End If
Parameter("OutURL")=""
Set Currobj=Browser("title:="&browsernm,"CreationTime:=0").Page("title:="&pagenm)

If parameter("Searchstr")<>"" Then
If Currobj.WebEdit("name:=q").exist Then
Currobj.WebEdit("name:=q").Set Parameter("Searchstr")
reporter.ReportEvent micPass,"searchvalue","search value set successfully"

Parameter("OutURL")=Currobj.WebElement("innertext:=qtp.blogspot.com/2007/11/qtp-test-parameters_11.html").GetROProperty("innertext")
reporter.ReportEvent micPass,"linkvalue","Link value set properly"
else
reporter.ReportEvent micFail, "searchvalue","search value not set successfully"
End If
End If

Sample Script2

Dim browsernm,pagenm
On Error Resume Next
Err.Clear
Dim testset, n
Set testset = QCUtil.CurrentTestSet
n = testset.name
If Err.Number <> 0 Then
Errr.Clear
End If

'Debug Declaration
If n = "" Then
Parameter("InURL")=""
end if

If parameter("InURL")<>"" Then
SystemUtil.Run "iexplore.exe",Parameter("InURL") reporter.ReportEvent micPass,"IEopen","Google open"
End If

QTP-Parameter Types

What is Parameter and Types of Parameters in QTP?

Parameters facilitate re-usability of an Action or a Test. By using parameters, you can record a test once and use it several times. Parameters enable you to run multiple sets of data.

Note: An input Parameter is a placeholder for a value that is passed to the test during the test run.

Parameter Types: By default, a test runs once for the recorded values. To run a test for multiple values,parametrize the test. The types of parameters in QuickTest are:

1. Input parameter: Enables you to run a test using different sets of input values.

For example, you can use input parameter to select different destinations for the same source in the Flight Reservation Application .

2. Output parameter : Enables you to use output to capture values from the application at run-time. You can get a value from the application and store it in the QuickTest test Results. You can later use this value as an input to a variable.

3. Random Number parameter: A system-generated number that is generated during a test run.

4. Environment parameter : A variable that describes a software or hardware object in the application under test environment. Examples are operating system version or Local host name.

Monday, May 16, 2011

SQL Queries

SQL Queries


Query for find n th highest salary

SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 3 salary
FROM dbo.empsalary
ORDER BY salary DESC) a
ORDER BY salary

To find the size of database

SELECT * FROM SYSFILE
USE URDBNAME
EXEC SP_HELPDB
EXEC SP_SPACEUSED

Create table from existing table

CREATE TABLE tblname (colnm) AS SELECT colnm FROM existingtblname

Precondition: table should already exist in select clause, number of column should be same and data type should be same.

To copy only structure of table not data

CREATE TABLE tblname AS SELECT *FROM existingtblnm WHERE (any false condition)
Example: Create table tblname as select * from existingtblnm where 1=2

To insert record into table from existing table

Precondition: both the table exist and data type must same
INSERT INTO table1 AS SELECT * FROM table2

Rename table

RENAME oldtblnm TO newtblnm

Drop table

DROP tablenm

To identify how many tables are there

SELECT *FROM TAB

To see the fields of table

DESC tablename

DUAL

In build table in oracle, only 1 row and 1 column,for getting output on screen of operations or system date
Example: select 2*2 from dual, select sysdate from dual

For viewing tables, views, SP,function from database

SELECT name,xtype FROM sysobjects WHERE xtype in (‘u’,’v’,’p’,’fn’) AND name NOT LIKE ‘dt%’ ORDER BY xtype