如何在Cypress.io中拖放

拉玛亚洲

我正在测试Trello,并尝试拖动最后一个列表,然后将其放入倒数第二列,但是没有“ .wait”,该测试将无法正常工作。如果有人可以就这里的潜在问题提供建议,那将非常有帮助,因为我更喜欢避免使用“ .wait”。没有抛出任何错误,但是如果没有“ .wait”,拖放操作就不会发生。

describe("Moving list", () => {
  it("Waiting For Accept list should be moved from last column to the penultimate column", () => {
    cy.get("#board")
      .children(".js-list")
      .should("have.length", 4)
      .and("be.visible");

    cy.get(":nth-child(4) > .list")
      .should("be.visible")
      .and("contain", "Waiting For Accept")

    cy.get(":nth-child(4) > .list").trigger("mousedown", {
      which: 1
    });

    cy.get("#board > div:nth-child(2) > .list")
      .trigger("mousemove");

    cy.get("#board > div:nth-child(3) > .list")
      .trigger("mousemove")
      .trigger("mouseup");

    cy.get(":nth-child(3) > .list")
      .should("contain", "Waiting For Accept");
  });
});

看图片

看图片

拉玛亚洲

最后,我使用“ cy.request”解决了这个问题

https://docs.cypress.io/api/commands/request.html#Syntax

describe("Moving list", () => {
        it("Waiting For Accept list should be moved from last column to the penultimate column", () => {
            cy.request("https://trello.com/b/9lfzKIRu/trello-tests").then(response => {
                expect(response.status).to.eq(200);
            });
            cy.get("#board > div:nth-child(4) > .list").trigger("mousedown", {
                which: 1
            });
            cy.get("#board > div:nth-child(2) > .list").trigger("mousemove");
            cy.get("#board > div:nth-child(3) > .list")
                .trigger("mousemove")
                .trigger("mouseup");
            cy.get(":nth-child(3) > .list").should("contain", "Waiting For Accept");
        });
    });

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章