正文

setup

(2011-06-15 12:33:42) 下一個

Data Table Pane


Data Table Overview
QuickTest enables you to insert and run steps that are driven by data stored in the data table. The data your test uses is stored in the design-time data table, which is displayed in the Data Table pane.

The data table has the characteristics of a Microsoft Excel spreadsheet, enabling you to store and use data in its cells and also perform mathematical formulas within the cells.

You can use the DataTable, DTSheet and DTParameter utility objects to manipulate the data in any cell in the data table.

How QuickTest Uses Data Tables
During the run session, QuickTest creates a run-time data table—a live version of the data table associated with your test. During the run session, QuickTest displays the run-time data in the Data Table pane so that you can see any changes to the data table as they occur.

When the run session ends, the run-time data table closes, and the Data Table pane again displays the stored design-time data table. Data entered in the run-time data table during the run session is not saved with the test. The final data from the run-time data table is displayed in the Run-Time Data Table in the Run Results Viewer.

Data Table Sheets
When working with tests, the data table has two types of data sheets—
Global and Action.
Global Sheet. You store data in the Global tab when you want it to be
available to all actions in your test and you want the data to control the
number of test iterations.
Action Sheets. You store data in the action’s tab when you want to use the
data in data table parameters for that action only and you want the data
to control the number of action iterations.Each time you add a new action to the test, a new action sheet is added to
the data table. Action sheets are automatically labeled with the exact name of the corresponding action.


Data Table - Save Options

Whenever you save your test, QuickTest automatically saves its data table as an .xls file.You can save the data table in another location and instruct the test to use
this data table when running a test. You specify a name and location for the data table in the Resources pane of the Test Settings dialog box.

If it is important for you to save the resulting data from the run-time data table, you can insert a DataTable.Export statement to the end of your test to export the run-time data table to a file. You can then import the data to the design-time data table using the data table’s File > Import From File menu. Alternatively you can add a DataTable.Import statement to the beginning of your test.

Formulas in Data Tables
You can use Microsoft Excel formulas in your data table.You can also use formulas as part of a checkpoint to check that objects created on-the-fly (dynamically generated) or other variable objects in your Web page or application have the values you expect for a given context.
For example, suppose you want to parameterize the value for a WebEdit object that requires a date value no earlier than today’s date. You can set the cells in the Date column to the date format, and enter the =NOW() Excel formula into the first row to set the value to today’s date for the first iteration.

Define the number of iterations for an action or test
? For actions: Open the Run tab of the Action Call Properties dialog box (Edit > Action > Action Call Properties > Run tab).
? For tests: Open the Run pane of the Settings dialog box (File > Settings > Run pane).
? If you want to prevent QuickTest from running an iteration on a row when the Run on all rows option is selected, you must delete the entire
row from the data table. To do this, do one of the following:
? Select the row, right-click in the table, and select Edit > Delete from the data table’s context menu (or use CTRL+K). This restores the bottom grid line from black to gray.
? Use the Clear option from the table’s Edit menu (or CTRL+X).
? Select a cell and press Delete on the keyboard. The data is deleted from the cells, but the row is not deleted and the black line remains. This means that QuickTest will run an iteration for this row even though there is no data in it.

Guidelines for Working with the Data Table
? When you add data to the data table, you must enter the data in rows from top to bottom and left to right—you cannot leave a gap of an entire row or column.
? The value returned from the data table is always converted to a string. If you want the value to be converted to something other than a string, you can use VBScript conversion functions, such as CInt, CLng, CDbl, and so forth. For example:Window("Flight Reservation").WinComboBox("Fly From:").Select
CInt(DataTable("ItemNumber", dtGlobalSheet))


Task:

Use datatable parameterizing values: Login, select city

Insert Formulas into Data Tables for Use in Checkpoints: Check Date on NewTours website.
Import Data Using Microsoft Query: check city

coding sample: close and open browser


Import Data Using Excel

setup script:


 Dim fpath 
 
 'import datatable
 fpath = Environment("TestDir")
 Environment.Value("fpathDataTable") = fpath & "Datatables" & "default.xls"
 datatable.Import(Environment.Value("fpathDataTable"))

 'close open browser
 do while("True")
 anyOpenbrowser = Browser("index:=0").Exist(0)
    if(anyOpenbrowser = "False") then
        exit do
    else
        Browser("index:=0").close
        end if
 loop

 'open a new browser
 
 set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = true
    IE.Navigate "http://newtours.demoaut.com/"

   


kURL =  "http://newtours.demoaut.com"
dim objShell
set objShell = CreateObject("Shell.Application")
objShell.ShellExecute kURL, "", "", "open", 1
set objShell = nothing

[ 打印 ]
閱讀 ()評論 (0)
評論
目前還沒有任何評論
登錄後才可評論.