- 4 minutes to read
The Test Editor allows you to view and modify tests and hooks. To open the editor, double-click the test or hook in the Explorer panel or click the corresponding row in the Fixture Editor. TestCafe Studio automatically opens the test in the editor when you create an empty test or start recording a new test.
The Test Editor consists of the following parts:
The toolbar - Displays navigation links and buttons for common tasks.
Click View Fixture to open the fixture in the Fixture Editor. The Open Tested Page link opens the browser and navigates to the tested page.
The test area - Displays the current test's content.
- The Actions panel - Lists actions you can add to the test. The actions are organized into categories. You can click the arrows next to category names to expand or collapse categories.
Add Actions From the Actions Panel
Click an action in the Actions panel to add it to the test or hook. TestCafe Studio adds the action to the last position and allows you to specify action parameters.
You can add actions after or during recording. When you add actions during the recording, you can pick an element on a web page to set it as an action parameter (for example, Element Selector for on-page actions or assertions).
You can record on-page actions and append them to the current test.
Click the Record test actions button on the toolbar to start recording. TestCafe Studio replays the existing actions and stops after the last action (the after each hook is not executed). If the test fails, the playback ends after the last successful action.
Now you can interact with the tested page. TestCafe Studio records your activity and appends new actions to the test.
To stop recording, close the browser or click the button on the editor's toolbar.
However, you can record new steps if playback stops inside a hook because of a failed action. These steps are added to the end of the hook in this case.
Click the Run test button on the editor's toolbar to run the test.
This button is not displayed for hooks. You cannot run a hook separately.
Modify Actions' Parameters
Click the action's row to expand the action parameters area that allows you to view or modify action parameters.
Change an Action's Position
Hover the mouse pointer over the button to the left of the action's name until the icon changes to the icon and then drag the action to a new position.
Copy/Cut and Paste Actions
You can copy or cut actions and paste them in different tests or hooks.
- Click actions to select them. Hold Cmd/Ctrl and click to select multiple actions. Press Cmd/Ctrl-A to select all actions in a test or hook.
- Press Cmd/Ctrl-C to copy the selected actions. TestCafe Studio displays a confirmation message: Actions copied. To cut these actions, press Cmd/Ctrl-X.
- Open the test or hook where you want to paste these actions and press Cmd/Ctrl-V.
The copied actions are inserted before the first selected action, or appended at the end of the test (or hook) if no action is selected.
Move Actions to a Hook
- Select actions you want to move. Hold Cmd/Ctrl and click to select multiple actions. Press Cmd/Ctrl-A to select all actions in a test.
- Click Move to 'before each' hook or Move to 'after each' hook.
Navigate to a Hook
The Test Editor displays the before each and after each steps if this fixture contains a corresponding hook. You can click these steps to navigate to the hook.
Collapse All Actions
Click the Collapse all actions button to collapse parameter areas for all test actions.
To delete a single action, hover the mouse pointer over the action's row and click the row's Remove action button.
To delete multiple actions, do the following:
- Select actions you want to delete. Hold Cmd/Ctrl and click the action's rows or press Cmd/Ctrl-A to select all actions in a test.
- Click the Remove selected actions button.
TestCafe Studio creates the test file in the same test directory and displays it in the Explorer panel.