Generate With statements

Relevant for: GUI tests and scripted GUI components

Generate With statements while recording

  1. 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.

  2. 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.

  3. 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.

Back to top

Generate With statements for existing actions

  1. 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.

  2. Confirm that the proper number is set for the Generate "With" statements for __ or more objects. The default is 2.

  3. Display the action for which you want to generate With statements.

  4. 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.

Back to top

Remove With statements

  1. Display the action for which you want to remove With statements.

  2. In the Editor, select Edit > Format > Remove "With" Statements. The Remove "With" Results window opens.

  3. To confirm the results, click OK. The With statements are replaced with the standard statement format.

Back to top