How to use the Cypress Test Code Generator
- 1. Write the stepsOne per line, using the simple step language below the box.
- 2. Name the testSet the describe block, test name and base URL.
- 3. GenerateSave the spec in cypress/e2e and run npx cypress run.
How the commands are built
The steps box takes the same short commands as our Playwright and Selenium generators, so one test description can be turned into any of the three: for example select #course = Data Analytics, check #remember, press Enter and expect value #email = asha@example.com. Selectors can be CSS, or text=, label=, placeholder=, testid= and role=, which survive design changes better than long CSS paths. Everything runs in your browser; nothing you enter is uploaded.
Each step becomes a Cypress chain: cy.visit, cy.get(…).clear().type(…), .select(), .check() and .click(), with checks like cy.url().should('include', …) and cy.contains(…).should('be.visible'). Cypress retries these automatically. Curly braces in typed text are escaped, because Cypress treats {enter} and similar as special keys, and label selectors find the input through the label's for attribute.
Worked example
The sample login and logout flow becomes a 13-line spec inside describe('Student portal', …). The email field is found with cy.contains('label', 'Email').invoke('attr', 'for'), the logout button with cy.get('[data-testid="logout"]'), and the URL check is cy.url().should('include', '/dashboard'). Cypress itself couldn't be installed in our test setup, so we checked the commands by replaying them in a real browser against a local login page.
Tips
- Add
data-testidordata-cyattributes to key elements; Cypress recommends them. - Log in through an API call or
cy.session()in other tests, instead of the UI every time. - Avoid
cy.wait(ms); wait for the element or request you need.
Frequently asked questions
Can Cypress test several browser tabs?
No; Cypress runs inside one tab. For multi-tab flows, Playwright is a better fit.
Does it work with Cypress 13+?
Yes. The config uses the defineConfig format introduced in Cypress 10.
Is the Cypress test generator free?
Yes. You can open the Cypress test generator and fill in everything without signing up. When you generate code for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.