Link Search Menu Expand Document

Cypress Command: clickCodeBlockContaining

Summary

cy.clickCodeBlockContaining(uniqueSubstring) - Find a code block containing `uniqueString` and then call `clickCodeBlock` with it

Parameters

  • uniqueSubstring - A substring within the executable code block you would like to click that is not contained within any other executable code block on the page

Example

cy.clickCodeBlockContaining("apt-get install");

Waiting

This command will wait until the command completes, unless otherwise specified by annotations.

Verification

This command will verify that the command succeeds, unless otherwise specified by annotations.

If the code block contains multiple commands, only the exit status of the last command will be checked for success. Authors are encouraged to use && to connect shell commands when there are multiple in a single block so that output from a subsequent command will not obscure the failure of a prior command.

Instruction-Guided

This is an instruction-guided command: By using this command to ask Cypress to click on a code block rather than typing directly into the terminal with terminalType, you will avoid having to remember to update your tests every time the contents of the code block changes.