【问题标题】:How to change the selector in the query using Cypress如何使用赛普拉斯更改查询中的选择器
【发布时间】:2023-03-28 19:28:01
【问题描述】:

我想测试我的表,为此我首先检查表是否包含特定的测试数据,然后我想选择删除按钮并单击它。我的问题是选择行时如何选择删除按钮?

这是我的 Cypress 脚本:

describe('Form', () => {  
  it('table contains test datat', () => {
    cy.get('table').contains('td', 'Awww, c\'est un bummer');
  }) 
})

还有我的餐桌代码:

据我了解,我的脚本在单元格上放置了一个选择器,因此我应该能够将其与 .then() 链接,但我不知道如何获取删除按钮

【问题讨论】:

    标签: javascript cypress


    【解决方案1】:

    我可以使用:

      it('it deletes the selected line', () => {
         cy.contains('td', 'Awww, c\'est un bummer')  // gives you the cell 
          .siblings()                            // gives you all the other cells in the row
          .contains('button', 'Annuler')               // finds the delete button
          .click()
      })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-21
      • 1970-01-01
      • 2019-02-12
      相关资源
      最近更新 更多