cypress-plugin-tab

<div align="center"> <h1>cypress-plugin-tab</h1> <a href="https://www.npmjs.com/package/cypress-plugin-tab"><img src="https://img.shields.io/npm/v/cypress-plugin-tab.svg?style=flat"></a> <a href="https://www.npmjs.com/package/cypress-plugin-ta

MIT 7 个版本
安装
npm install cypress-plugin-tab
yarn add cypress-plugin-tab
pnpm add cypress-plugin-tab
bun add cypress-plugin-tab
README

cypress-plugin-tab

A Cypress plugin to add a tab command

Installation

This package supports Cypress 10+.

  1. Install the plugin:
npm install -D cypress-plugin-tab
  1. Load it from your Cypress support file at cypress/support/e2e.js:
require('cypress-plugin-tab')

If your support file is TypeScript, use:

import 'cypress-plugin-tab'
  1. Make sure your Cypress config points at that support file. Example cypress.config.js:
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    supportFile: 'cypress/support/e2e.js',
  },
})
  1. If you use TypeScript and want the custom command typed in editors, add the package to your Cypress tsconfig:
{
  "compilerOptions": {
    "types": ["cypress", "cypress-plugin-tab"]
  }
}

Usage

  • .tab() must be chained off of a tabbable(focusable) subject, or the body
  • .tab() changes the subject to the newly focused element after pressing tab
  • .tab({ shift: true }) sends a shift-tab to the element
cy.get('input').type('hello').tab().type('world') // type foo, then press tab, then type bar
cy.get('body').tab() // tab into the first tabbable element on the page
cy.focused().tab() // tab into the currently focused element

shift+tab:

cy.get('input')
  .type('hwllo')
  .tab()
  .type('world')
  .tab({ shift: true })
  .type('hello') // correct your mistake

License

MIT

版本列表
2.0.0 2026-03-02
1.0.5 2019-12-20
1.0.4 2019-12-05
1.0.3 2019-09-20
1.0.2 2019-09-20
1.0.1 2019-05-23
1.0.0 2019-03-05