cypress-get-by-label

Example custom Cypress command finding form element by its label

Usage no npm install needed!

<script type="module">
  import cypressGetByLabel from 'https://cdn.skypack.dev/cypress-get-by-label';
</script>

README

cypress-get-by-label ci status renovate-app badge cypress version

Example custom Cypress command finding form element by its label

Read How to Publish Custom Cypress Command on NPM

install

npm i -D cypress-get-by-label
# or
yarn add -D cypress-get-by-label

use

Include from your Cypress support file or individual spec

const { registerCommand } = require('cypress-get-by-label')
registerCommand()
// or we could register under a different name
registerCommand('getFormField')

Then use the command cy.getByLabel (default) or the custom name

// if used registerCommand()
cy.getByLabel('First name:')
// if used registerCommand('getFormField')
cy.getFormField('First name:')

types

To get IntelliSense working with the default custom command cy.getByLabel include in your specs

/// <reference types="cypress-get-by-label" />

For example in VSCode you will see

IntelliSense

examples