IntelliJ IDEA 2023.2 Help

Cypress

Aqua plugin icons cypress Cypress is an open-source testing framework for web applications. It provides developers with a fast and reliable solution for automating end-to-end tests. With its unique architecture and comprehensive feature set, Cypress enables efficient test writing, debugging, and integration with popular frameworks and CI/CD pipelines.

Create a new Cypress project

  1. From the main menu, select File | New | Project.

    Alternatively, if you're on the Welcome screen, click New Project.

  2. From the list on the left, select Cypress.

  3. Name the new project and change its location if necessary.

  4. Optionally, enable the Create Git repository parameter to place the new project under version control.

    You will be able to do it later at any time.

  5. From the Language list, select the language that you want to use.

  6. Optionally, enable the Add sample code parameter.

  7. Optionally, enable the parameter to create a set of support files used to introduce custom commands or global overrides that will apply to your spec files.

  8. Optionally, enable the Configure component tests parameter to set up and configure a framework for component testing. Once the Configure component tests parameter is enabled, select the desired framework from the list.

    Create a Cypress project with component tests
  9. Click Create.

    Creating a new Cypress project

A new project is created according to the options that you have selected.

Add elements to code

  1. Open the file where you want to add an element.

  2. Click the Web Inspector button on the right-hand sidebar to open the Web Inspector toolbar window.

  3. Specify the URL of the page in the address bar.

    Address bar controls

  4. Click The Select Element in Page button and select the element that you want to add in the Web Inspector.

    Select element in page

  5. Once the element is selected, click Add Element to Code to add the element to the code.

    The Add Element to Code button

    To add a specific type of the selector (ID, Name, Tag with classes, and so on), click Add Element to Code By and select the required option.

    Add elements to code by

    If you want to switch specifically between CSS and XPath locators, click Aqua plugin icons locators expui css and select the required locator type.

    Select locator type

As a result, a piece of code is generated and added to the code editor.

Customize the locator template

If you want to customize how selected elements are added to your code, you can modify the template:

  1. Click the framework name on the Status bar. The UI Automation Framework menu opens.

    Customize template
  2. Select the Customize Template option.

  3. In the File and Code Templates dialog, select the required framework from the list.

    The File and Code Templates dialog
  4. Rewrite the code generation algorithms for the web element locator.

  5. Click OK to save changes.

As a result, the locators will be added to the code according to the updated code generation algorithms.

Run tests

  • To run your tests, click the the Run button gutter icon next to the test class or test method, then select the Run option from the list.

    Run tests

    Alternatively, place the caret at the test class to run all tests in that class, or at the test method, and press Control+Shift+F10.

You can run tests in a more customizable way using the run/debug configurations. For more information, refer to Run tests.

Review test results

When the tests finish running, the results are displayed on the Test Runner tab of the Run tool window. On this tab, you can rerun tests, export and import test results, see how much time it took to run each test, and perform other actions.

Test results shown on the Test Runner tab of the Run tool window

For more information, refer to Explore test results.

Modify a run/debug configuration

If you want to modify the startup properties for your tests, edit the run/debug configuration:

  1. Click the current configuration in the run/debug configuration switcher and select the Edit Configurations... option.

    Select the run/debug configuration
  2. In the Run/Debug Configurations dialog, configure the required startup properties.

    Configure startup properties

For more information on run/debug configurations, refer to Run/debug configurations.

Open Cypress Launchpad

If needed, you can open your current project in Cypress Launchpad. To do this, click the Open Cypress button.

Open Cypress Launchpad
Last modified: 25 October 2023