Home / Companies / Cypress / Blog / Post Details
Content Deep Dive

How cy.prompt generates cy.contains, cy.press, and handles sensitive data

Blog post from Cypress

Post Details
Company
Date Published
Author
-
Word Count
656
Language
English
Hacker News Points
-
Summary

In a recent update, cy.prompt, a tool for writing tests, now enhances its functionality by generating cy.contains and cy.press commands, and improving the handling of sensitive data. The update facilitates writing cy.prompt steps by using quoted text to generate cy.contains() for exact text matches, which is beneficial when the content is stable but selectors are not. For structural targeting where selectors are stable, cy.get() is used without quotes. The changes also include support for not.exist assertions using text-based targeting, ensuring elements are not just hidden but removed from the DOM, and introducing cy.press for keyboard interaction testing, crucial for accessible workflows. Furthermore, cy.prompt now excludes sensitive data such as passwords and credit card details from being sent to the AI model while still using the surrounding context for interaction, which is particularly important in testing login forms and checkout processes. These updates aim to improve test accuracy and security, and users are encouraged to explore the updated documentation or seek help from the Cypress Discord for any issues.