i have a 2d chart made with d3.js and i should test it with cypress. First I wanted to make the dots move
<circle id="MYID" class="clickable handler" r="5" htmlTemplate="pippo" cx="1144.6314588049954" cy="298.9141325106507"></circle>
I tried these solutions (one of the 2 is commmented) but it doesn't work:
cy.get('[id="MYID"]')
// .trigger('mousedown', { which: 1, force: true, view: window })
// .trigger('mousemove', { position: 'top', view: window })
// .trigger('mouseup', { position: 'top', force: true });
.trigger('mousedown', {
which: 1,
force: true,
view: window,
})
.trigger('mousemove', {
clientX: 3000,
clientY: 5000,
force: true,
})
.trigger('mouseup', {
force: true,
view: window,
});
});
In the case commented it seems to move, but it is millimetric, I would like to reproduce a real and propsio displacement of the ball, but as I did it it does not move a millimeter!
CodePudding user response:
I solved it like this:
cy.window().then(window => {
cy.get('[id="MYID"]')
.trigger('mousedown', {
which: 1,
force: true,
view: window,
})
.trigger('mousemove', {
clientX: 300,
clientY: 500,
force: true,
})
.trigger('mouseup', {
force: true,
view: window,
});
});