【问题标题】:cypress to test handsontablecypress 测试handsontable
【发布时间】:2019-05-06 04:34:34
【问题描述】:

我正在使用 cypress 进行 e2e 测试。有一个屏幕我使用handsontable。它类似于 Excel 工作表。我无法使用 cypress 将内容写入其单元格,因为该单元格实际上只是一个 td,但在内部它在编辑时被映射到 textarea

有人可以提供一个测试,使用 cypress 在其单元格中输入文本吗?

我绑定了以下,但它不起作用。

cy.get('.handsontable tbody tr:nth-child(1) td:nth-child(2)').dblclick().type('test');

【问题讨论】:

    标签: handsontable cypress


    【解决方案1】:

    如果无法输入类型,您可以尝试在标识字段中粘贴text,如下所示;我已经运行了以下测试,我可以将AUD 粘贴到第一行的currency 列中。我在 Windows 10 操作系统上使用 cypress 版本 3.1.2,带有 Chrome 70 测试运行器

    describe("Cypress test on handsontable", function() {
      it("Some test on handsontable", function() {
      cy.visit("https://handsontable.com/examples?headers")
      cy.get('.handsontable tbody tr:nth-child(1) td:nth-child(5)').then($td => {
          $td.text('AUD');
         });
       });
    });
    

    【讨论】:

      【解决方案2】:

      我能够输入具有以下规格的单元格。

      context('handsontable', () => {
        it('handsontable', () => {
          cy.visit("https://handsontable.com/examples?headers");
          cy.get('.handsontable tbody > :nth-child(10) > :nth-child(2)').click().click().get('.handsontableInput').type('test');
        })
      })
      

      由于某种原因,dblclick() 不起作用。

      【讨论】:

      • 点击调用编辑模式是要走的路。用户无法根据其他答案直接更改文本,因此该测试无效(即使它成功)。
      猜你喜欢
      • 2019-06-21
      • 2019-08-22
      • 2021-10-30
      • 2022-06-29
      • 1970-01-01
      • 2021-11-05
      • 1970-01-01
      • 2021-03-25
      • 2019-12-27
      相关资源
      最近更新 更多