Lesson 8: Insert Java custom code
You can switch to Java scripting if you want to insert
Java codes to perform additional operations such as extending an API
or any functions that cannot be performed directly in the simplified
script editor.
About this task
In this lesson, you insert a Java code snippet so that Rational® Functional Tester waits until the Password control in the Member Logon window is displayed in the application during playback and then test the control.
You can enable the option to wait for the control to be displayed for a test line in the Playback page in the Properties view. But in this tutorial, to understand the process of inserting a custom Java code, you perform the following steps:
Procedure
- Select the test line Click Password in the script editor. (The first test line in the Member Logon group.)
- Right-click and select Insert Java Code Snippet. The test line Click here to tag the Java snippet test line is inserted after the Click Password.
- Select the inserted test line and replace the test line text by typing Wait for control.
- Drag the Wait for the control test
line and drop it above the Click Password test line
so that Java code is executed before the password control is tested.
- Click to save the simplified script.
- Click Java editor that is displayed next to the Script editor. Notice that Wait for control is displayed as comments with the start and the end point for inserting the Java code in the Java editor.
- Type the Java code password().waitForExistence(); within
the start and the end comment section.
- Click to save the Java script.
Play back the script
About this task
Procedure
Lesson checkpoint
In this lesson you learned how to modify the simplified
test script and insert a Java custom code snippet to a simplified
script.