The Test Recorder is a tool for recording user operations on applications and generating a test script from the recorded steps.
The Test Recorder is supported for Web applications running on Chrome and Firefox (on all supported platforms) and on Safari (on Mac).
Test Recorder benefits
The Test Recorder is a useful tool for accelerating test creation and can be beneficial for:
- Creating the main body of a test, which you can later refine by adding verifications and synchronizations.
- Learning how to write tests gradually, assisting in your learning curve.
- Quickly adding steps to an existing test.
- Make sure that your browser is set up with the LeanFT extension. For details, see Set up web browsers and controls.
- Make sure that the LeanFT runtime engine is configured to use the Web add-in, as described in Customize LeanFT runtime engine settings.
Record GUI operations using the Test Recorder
You can record on several browsers at a time.
To record GUI operations:
- In your IDE, open an existing test or create a new one.
From your IDE menu, click LeanFT > Test Recorder or click the Test Recorder button.
The IDE is minimized and the Test Recorder toolbar appears at the top of the screen.
The Test Recorder does not start recording automatically. Bring your application to the desired state before you start recording.
On the Test Recorder toolbar, click the Start Recording button.
- Perform operations on your application. Each operation that you perform is recorded and a description for that operation is displayed as a step in the toolbar.
At any point during the recording session, you can do the following:
Review the steps that you recorded. In the Test Recorder toolbar, click the down arrow to display the steps.
Note: On some platforms the steps list may display with wide black margins.
Add comments to the recorded steps.
To add a comment, in the Test Recorder toolbar, click the down arrow to display the steps, hover over the step to which you want to add the comment, click //click to add comment, and enter the text. You can add a comment to the last recorded step directly in the toolbar.
The comment will be added to the code after you generate it. You can also add comments to the code after you complete the recording session.
Pause the recording session if you want to perform an operation that you do not want to record. For example, closing a pop-up dialog box that is not part of the test flow.
In the Test Recorder toolbar, click the Pause button. To resume the session, click the Resume button and continue recording.
Delete Delete a step. Click the down arrow to display the steps, hover over the step you want to delete, and then click the Delete button. Exit Exit the session. Click Exit to close the session without generating code.
When you are done recording, click the Stop button.
The Recording Session Summary dialog box displays.
On the Recording Session Summary dialog box, you can do the following:
- Review the steps you recorded, delete unnecessary steps, and add comments.
- Redo the recording, discard the current session and begin a new recording. Click the New Recording button.
- When you are done, click the Generate script and copy to clipboard button, and then click Exit.
Paste the script into your test. Add verifications and synchronizations as needed. For more details, see Verifications.
How is code generated?
The Test Recorder is available on all IDEs supported by LeanFT: Eclipse, IntelliJ IDEA and Visual Studio. In Eclipse and IntelliJ IDEA the code is generated in Java. In Visual Studio, the code is generated in C#.
The script created is self-contained and includes all the object identifications required using descriptive programming. It also includes any comments added to document the operations performed during your recording session.
The code is based on the LeanFT SDK and, typically, has the following format:
Browser browser = BrowserFactory.launch(BrowserType.CHROME); // This is a demo application browser.navigate("http://www.advantageonlineshopping.com/"); // Click the user button browser.describe(Link.class, new LinkDescription.Builder() .innerText("My account My Orders Sign out ") .tagName("A").build()).click(); // Create a new user account browser.describe(Link.class, new LinkDescription.Builder() .innerText("CREATE NEW ACCOUNT") .tagName("A").build()).click(); browser.describe(EditField.class, new EditFieldDescription.Builder() .name("usernameRegisterPage") .tagName("INPUT") .type("text").build()).setValue("johndoe"); browser.describe(EditField.class, new EditFieldDescription.Builder() .name("emailRegisterPage") .tagName("INPUT") .type("text").build()).setValue("email@example.com");
The object identification is based on the definitions configured in the LeanFT engine object identification settings.
You can configure the default settings. Any change that you make affects how objects are identified in both the Object Identification Center and in the Test Recorder generated code. For more details, see Customize how to identify objects (Windows only).