Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
WR DB Connectivity,DDT,EH

WR DB Connectivity,DDT,EH

Ratings: (0)|Views: 132 |Likes:
Published by api-3756170
Winrunner DB Connectivity, Data Driven Test, Exception handling
Winrunner DB Connectivity, Data Driven Test, Exception handling

More info:

Published by: api-3756170 on Oct 18, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

05/09/2014

pdf

text

original

USING DATA BASE CONNECTIVITY IN WINRUNNER
1) compares current database data to expected database data.
db_check ( checklist, expected_results_file [ , max_rows [ , parameter_array ] ] );

In the following example, db_check creates a database checkpoint. "list_1.cdl" is the
name assigned to the database checklist captured for a test script; "dbvf1" indicates the
expected_results_file captured for this test.

db_check("list1.cdl", "dbvf1");

In the following example, db_check creates a database checkpoint. The parameters for
the SQL statement are in an array in the fourth parameter of the db_check statement.
param_array[1] = 3;
param_array[2] = 7;
db_check ("list1.cdl", "dbvf1", NO_LIMIT, param_array);

2) creates a new database session and establishes a connection to an ODBC database.
db_connect ( session_name, connection_string );
session_name The logical name of the database session.
connection_string

The connection parameters to the ODBC database.
In the following example, WinRunner creates the "query1" database session and
establishes a connection to an ODBC database using the "DSN=Flight32" connection
string.

db_connect ("query1","DSN=Flight32");
3) disconnects from the database and ends the database session.
db_disconnect ( session_name );
In the following example, WinRunner disconnects from the "query1" database session.
db_disconnect ("query1");
4) executes the query based on the SQL statement and creates a record set.
db_execute_query ( session_name, SQL, record_number );

session_name The logical name of the database session.
SQL The SQL statement.
record_number An out parameter returning the number of records in the result query.
The db_execute_query function executes the query based on the SQL statement and
creates a record set.
In the following example, WinRunner executes the query based on the "SELECT *
FROM Orders" SQL statement and creates the record set, which has record_number
records.

db_execute_query ("query1","SELECT * FROM Orders",record_number);
5) returns the value of a single field in the database.
db_get_field_value ( session_name, row_index, column );
session_name The logical name of the database session.
row_index

The index of the row written as a string: "# followed by the numeric index.
(The first row is always numbered "#0".)
column

Either the name of the field in the column, or the index of the column within the database written as a string: "# followed by the numeric index. (The first column is always numbered "#0".)

1

The db_get_field_value function returns the value of a single field in the specified
row_index and column in the session_name database session.
In case of an error, an empty string will be returned.
In each of the following examples, WinRunner returns the value of a single field in the
"query1" database session.

val = db_get_field_value ("query1","#1","#1");
val = db_get_field_value ("query1","#1","Customer_Name");
6) returns the number of column headers in a query and the content of the column
headers, concatenated and delimited by tabs.
db_get_headers ( session_name, header_count, header_content );

In the following example, WinRunner returns the number of column headers in the
"query1" database session and all the strings in all column headers, concatenated and
delimited by tabs.

db_get_headers ("query1",field_num,headers);
split (headers, header_arr, "\t");
7) returns the content of the row, concatenated and delimited by tabs.
db_get_row ( session_name, row_index, row_content );
In the following example, WinRunner returns the content of the row, concatenated and
delimited by tabs.
db_get_row("query1",5,row_content);
split(row_content, line_arr, "\t");
8) compares information that appears in the application under test during a test run with
the current values in the corresponding record(s) in your database.
db_record_check ( ChecklistFileName , SuccessConditions, RecordNumber );

ChecklistFileName A file created by WinRunner and saved in the test's checklist
folder. The file contains information about the data to be captured during the test run and
its corresponding field in the database. The file is created based on the information
entered in the Runtime Record Checkpoint wizard.

SuccessConditions : Contains one of the following values:
DVR_ONE_OR_MORE_MATCH - The checkpoint passes if one or more matching
database records are found.
DVR_ONE_MATCH - The checkpoint passes if exactly one matching database record is
found.
DVR_NO_MATCH - The checkpoint passes if no matching database records are
found.
RecordNumber:

An out parameter returning the number of records in the database.
The db_record_check function compares information that appears in the application
under test during a test run with the current values in the corresponding record(s) in your
database.
In the following example, db_record_check creates a runtime database record checkpoint.
"list_1.cvr" is the name assigned to the checklist captured for the test script;
"DVR_ONE_MATCH" indicates that the checkpoint will pass if one, and only one,
matching database record is found.

db_record_check("list1.cvr", DVR_ONE_MATCH, record_num);
2
USING DDT IN WR
1) creates or opens a data table file so that WinRunner can access it.
ddt_open ( data_table_name [ , mode ] );
data_table_name

The name of the data table. The name may be the table variable
name, the Microsoft Excel file or a tabbed text file name, or the full path and file name of
the table.The first row in the file contains the names of the parameters. This row is
labeled row 0.
mode The mode for opening the data table: DDT_MODE_READ (read-only) or
DDT_MODE_READWRITE (read or write). When the mode is not specified, the default
mode is DDT_MODE_READ.
The ddt_open function opens the data table file with the specified data_table_name. The
active row becomes row number 1.

2) closes a data table file.
ddt_close ( data_table_name );
ddt_close(table);

3)ddt_close_all_tab les();
The ddt_close_all_tables function closes all open tables in all open tests. Note that this
includes any tables that are open in the table editor, tables that were opened using the
ddt_open or ddt_show functions or/and using the DataDriven Tests Wizard.
In the following example, Test2 begins with the ddt_close_all_tests
function in order to close any open tables from any other open tests.

Test1:
# Open table1.
ddt_open(table1);
# Open table2.
ddt_open(table2);
# Open table3.
ddt_open(table3);
Test2:
# Open table4.
ddt_open(table4);
#Close all open tables (from both Test1 and Test2)
ddt_close_all_tests();
4) ddt_export ( data_table_namename1, data_table_namename2 );
data_table_namename1
The source data table filename.
data_table_namename2

The destination data table filename.
The ddt_export function sends the contents of data_table_name1 to data_table_name2.
In the following example, WinRunner exports the information from the Excel file entitled
"Default" to the Excel file entitled "flight".

ddt_export ( "C:\\mercury\\tmp\\merc1\\Default.xls" , "
C:\\mercury\\tmp\\merc1\\flight.xls" );
5) retrieves the active row of a data table.
ddt_get_current_row ( data_table_name, out_row );
data_table_name The name of the data table. The name may be the table variable name,
the Microsoft Excel file or a tabbed text file name, or the full path and file name of the3

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->