Recording a Java test script

Java scripts are generated when you work with the simplified scripts. You can switch to Java scripting using the Insert Java snippet and Insert Java module features in the simplified script editor.

Before you begin

Advanced users can opt to work solely with Java scripting. Use the recording feature of HCL OneTest UI to record actions on the test applications. The actions on the test applications are generated in the form of a Java test script when you stop recording.

Prerequisites:
  • Disable the Simplified Scripting feature on the HCL OneTest UI Preferences page. Alternatively, if you want to work with Java scripting only for the current script you will record, select Java Scripting from the Select Mode list in the Record a Functional Test Script dialog box.
  • The test application and the required environments must be configured for functional testing.

    HCL OneTest UI automatically enables the environments for functional testing. As a result, you can directly record functional test scripts without enabling components manually. The automatic enablement takes place under certain conditions and has limitations. For more information about the conditions and limitations, see Automatically enabled environment for functional testing.

  • A functional test project has been created.

About this task

All functional testing scripts use a default helper superclass. You can create your own helper superclass if you want to add additional methods or override the methods in RationalTestScript. For more information, see Changing the Default Script Helper Superclass.

Procedure

  1. Click Record a Functional Test Script(Record a Functional Test Script button).
  2. In the Record a Functional Test Script dialog box, select the project for the script to be a part of, and then type a name for the script.
    Note:
    • Script names cannot contain spaces or the following characters: $ \ / : & * ? " <> | # % -
    • The script name is appended to the project path. The project path and script name together should not exceed 230 characters.
  3. Make sure that Java Scripting is selected in the Select Mode list. You can make Java scripting as the default script mode by selecting the Default check box.
  4. Click Next.
  5. Optional: In the Select Script Assets page, modify the test object map and test dataset if you do not want to use the default settings.
  6. Click Finish to start recording.
    The Recording Monitor opens and the recording starts.
  7. In the Recording Monitor toolbar, click Start Application to start your test application.
  8. Perform test actions in the application.
    Note: To record the action of moving the mouse over a link that has a tooltip, move the mouse over the link so that the tooltip is displayed, and press Shift. This notifies the recorder to capture the action in the script.
  9. Optional: You can record verification points or data-drive your test script using the tools available in the Recording Monitor toolbar while recording the script.
  10. Optional: To insert statements to call another script, specify log information, timer or comments during recording, use the Insert Script Support Commands feature available in the Recording Monitor toolbar.
  11. Close your application, if you want closing the application to be part of the script.
  12. Click Stop recording (Stop recording button) when you finish recording.
    A Java test script is generated and displayed in the Java editor.