Generate With statements
Relevant for: GUI tests and scripted GUI components
This topic describes how to generate and remove With statements.
Generate With statements while recording
-
In the General pane of the GUI Testing tab of the Options dialog box (Tools > Options > GUI Testing tab > General tab), select Automatically generate "With" statements after recording option.
-
In the Generate "With" statements for __ or more objects box, enter the minimum number of consecutive, identical objects for which you want to apply the With statement. The default is 2.
-
Begin recording your test. While recording, statements are recorded normally. When you stop recording, the statements in all actions recorded during the current recording session are automatically converted to the With format.
Generate With statements for existing actions
-
In the General pane of the GUI Testing tab of the Options dialog box (Tools > Options > GUI Testing tab > General tab), select the Automatically generate "With" statements after recording option.
-
Confirm that the proper number is set for the Generate "With" statements for __ or more objects. The default is 2.
-
Display the action for which you want to generate With statements.
-
From the Editor, select Edit > Format > Apply "With" to Script. The "With" Generation Results window opens.
Each With statement contains only one object.
To confirm the generated results, click OK. The With statements are applied to the action.
Tip: If you type a With statement (as opposed to creating it using the procedure described above), select Edit > Format > Apply "With" to Script to enable statement completion within the With statement.
Remove With statements
-
Display the action for which you want to remove With statements.
-
In the Editor, select Edit > Format > Remove "With" Statements. The Remove "With" Results window opens.
-
To confirm the results, click OK. The With statements are replaced with the standard statement format.