且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Cypress.io中的选择器存储位置

更新时间:2023-08-21 19:44:40

您不需要做任何魔术.只需将选择器放入文件中,然后导入即可.

You don't need to do any magic. Simply put your selectors into a file, and import it.

// cypress/support/selectors.js

export default {
  mySelector: '.my-selector',
  mySelector2: '.my-selector-2'
};

// cypress/integration/one.spec.js

import selectors from '../support/selectors.js';

describe('test', () => {
  it('test', () => {
    cy.get(selectors.mySelector);
  });
});