Sie sind auf Seite 1von 5

TSL SCRIPTS FOR WEB TESTING

1.

web_browser_invoke ( browser, site );

// invokes the browser and opens a specified site. browser The name of browser (IE or NETSCAPE). site The address of the site.

2.

web_cursor_to_image ( image, x, y );

// moves the cursor to an image on a page. image The logical name of the image. x,y The x- and y-coordinates of the mouse pointer when moved to an image

3. web_cursor_to_label ( label, x, y );
// moves the cursor to a label on a page. label The name of the label. x,y The x- and y-coordinates of the mouse pointer when moved to a label.

4.web_cursor_to_link ( link, x, y );
// moves the cursor to a link on a page. link The name of the link. x,y The x- and y-coordinates of the mouse pointer when moved to a link.

5.web_cursor_to_obj ( object, x, y );
// moves the cursor to an object on a page. object The name of the object. x,y The x- and y-coordinates of the mouse pointer when moved to an object.

6.web_event ( object, event_name [, x , y ] );


// uns an event on a specified object. object The logical name of the recorded object. event_name The name of an event handler. x,y The x- and y-coordinates of the mouse pointer when moved to an object

7.web_file_browse ( object );
// clicks a browse button. object A file-type object.

8.web_file_set ( object, value );


// sets the text value in a file-type object. object A file-type object. Value A text string.

9. web_find_text ( frame, text_to_find, result_array [, text_before, text_after, index, show ] );


// returns the location of text within a frame.

10. web_frame_get_text ( frame, out_text [, text_before, text_after, index ] );


// retrieves the text content of a frame.

11.web_frame_get_text_count ( frame, regex_text_to_find , count );


// returns the number of occurrences of a regular expression in a frame.

12. web_frame_text_exists ( frame, text_to_find [, text_before, text_after ] );


// returns a text value if it is found in a frame.

13.web_get_run_event_mode ( out_mode );
// returns the current run mode out_mode The run mode in use. If the mode is FALSE, the default parameter, the test runs by mouse operations. If TRUE, is specified, the test runs by events.

14. web_get_timeout ( out_timeout );


// returns the maximum time that WinRunner waits for response from the web. out_timeout The maximum interval in seconds

15.web_image_click ( image, x, y );
// clicks a hypergraphic link or an image. image The logical name of the image. x,y The x- and y-coordinates of the mouse pointer when clicked on a hypergraphic link or an image.

16. web_label_click ( label );


// clicks the specified label. label The name of the label.

Declaring Constants The const indicates that the declared value cannot be modified. The syntax of this declaration is: [class] const name [= expression]; The class of a constant may be either public or static. If no class is explicitly declared, the constant is assigned the default class public. Declaring Arrays The following syntax is used to define the class and the initial expression of an array. Array size need not be defined in TSL. class array_name [ ] [=init_expression] The array class may be any of the classes used for variable declarations (auto, static, public, and extern). Note that arrays are initialized once, the first time a function is run. If the user edits the arrays initialization values, the new values will not be reflected in Subsequent test runs. To reset the array with the new initialization values, either interrupt test execution with the Stop command, or define the new array elements explicitly. Return Statement The return statement is used exclusively in functions. The syntax is: return ( [expression] ); This statement passes control back to the calling function or test. It also returns the value of the evaluated expression to the calling function or test. If no expression is assigned to the return statement, an empty string is returned. The texit statement can be used to stop a function or test run. The syntax is: texit ([ expression ] );

Compiled module

Compiled modules, like a regular test user create in TSL, can be opened, edited, and saved. User indicate that a test is a compiled module in the General tab of the Test Properties dialog box, by selecting Compiled Module in the Test Type box. The content of a compiled module differs from that of an ordinary test. For example, it cannot include checkpoints or any analog input. The purpose of a compiled module is to store the userdefined functions which user use most frequently so that they can be quickly and conveniently accessed from other tests. Unlike an ordinary test, all data objects (variables, constants, arrays) in a compiled module must be declared before use. If the user makes changes to a function in a loaded compiled module, user must unload and reload the compiled module in order for the changes to take effect. A compiled module may contain the following elements: Function definitions and declarations for variables, constants and arrays. Prototypes of external functions Load statements to other modules. User can use the Function Viewer to load and unload compiled modules, to copy, paste and execute the functions of loaded compiled modules and tests, and to open loaded compiled modules and tests containing loaded functions. The Function Viewer toolbar provides the following options: Load Enables user to load a compiled module. Unload Unloads the currently selected compiled module. Unload All Modules Unloads all compiled modules. This button does not have any effect on functions loaded from tests. Copy Copies the selected function prototype to the clipboard. Paste Copies and pastes the selected function prototype to the current cursor location in the test. Execute Executes the selected function. Go to Opens the selected compiled module, test, or function in the test Window.

Advantages of compile module Compiled modules can improve the organization and performance of the tests. Since user debug compiled modules before using them, tests that call functions from these modules require less error-checking. In addition, calling a function that is already compiled is significantly faster than interpreting a function in a test script. System and User Compiled Modules A system compiled module is a closed module that is not visible to the tester. It is not displayed in the test window when it is loaded, cannot be stepped into, and cannot be stopped by a pause command. A system module is not unloaded when the user execute an

unload statement with no parameters A user compiled module is the opposite of a system module in most respects. It is displayed when it runs and user can use all WinRunner debugging options to control the run. Generally, a user module is one that is still being developed. In such a module user might want to make changes and compile them incrementally. Loading and Unloading a Compiled Module User can load a module in one of three ways: Use the Load or Unload toolbar buttons in the Function Viewer to load or unload a compiled module. Load the module from a test script using the TSL load or reload functions. Run the module script using the WinRunner Run commands to load a module into memory with all its functions. To unload a module loaded this way, click the Stop button.

Das könnte Ihnen auch gefallen