cypress 对于获取文本异步promise



This content originally appeared on DEV Community and was authored by Dennis Zhang

Cypress.Commands.add('myCustomCommand', () => {
  return cy.get('.element').then(($el) => {
    // 如果你需要 Promise,请将其放在一个 Cypress 操作之外
    return new Cypress.Promise((resolve) => {
      setTimeout(() => {
        resolve($el);
        // resolve(cy.wrap(33)) // 将某个值重新包裹到 Cypress 命令链中

      }, 1000);
    });
  });
});



This content originally appeared on DEV Community and was authored by Dennis Zhang