我正在尝试用cypress点击chessground board上的一个片段。
出于某种原因,它没有触发点击事件。
我假设它与chessground如何绑定点击有关,或者与svg有关?
我试过几种方法:
cy.get("cg-board")
.should("be.visible")
.trigger("mousedown", offset.x, offset.y, {
force: true,
});
cy.get("svg.cg-shapes")
.should("be.visible")
.trigger("mousedown", offset.x, offset.y, {
force: true,
});
cy.get("svg.cg-custom-svgs")
.should("be.visible")
.trigger("mousedown", offset.x, offset.y, {
force: true,
});
cy.get("div.cg-wrap")
.should("be.visible")
.trigger("mousedown", offset.x, offset.y, {
force: true,
});
cy.get("piece.white.pawn:nth(1)")
.should("be.visible")
.trigger("mousedown", { force: true });
cy.get("cg-board").should("be.visible").click(offset.x, offset.y, {
force: true,
});
cy.get("svg.cg-shapes").should("be.visible").click(offset.x, offset.y, {
force: true,
});
cy.get("svg.cg-custom-svgs")
.should("be.visible")
.click(offset.x, offset.y, {
force: true,
});
cy.get("div.cg-wrap").should("be.visible").click(offset.x, offset.y, {
force: true,
});
cy.get("piece.white.pawn:nth(1)")
.should("be.visible")
.click({ force: true });
调试时,它似乎在点击:
1条答案
按热度按时间frebpwbc1#
问题是它忽略了不受信任的事件:
https://github.com/lichess-org/chessground/issues/267#issuecomment-1609845364
Drag有这条线: