https://cypress.io logo
How to simulate drawing with pointer-events?
# i-need-help
m
Hello folks! I'm attempting to test OSD-Annotorious using Cypress, and my goal is to draw a figure by clicking and dragging over an element. I've tried using
trigger()
with pointer events, but haven't been successful so far. Do you have any suggestions or tips on how to simulate a click-and-drag action in Cypress that would allow me to draw the desired figure? Any help would be appreciated!
Copy code
it('Should draw a rectangle', { scrollBehavior: false }, function () {
  cy.visit('https://recogito.github.io/annotorious/getting-started/');

  cy.wait(1500);

  cy.get('.a9s-annotationlayer')
    .trigger('pointerdown', {
      position: 'topLeft',
      force: true,
      x: 50,
      y: 50,
    })
    .trigger('pointermove', {
      position: 'topLeft',
      force: true,
      x: 150,
      y: 150,
    })
    .trigger('pointerup', {
      position: 'topLeft',
      force: true,
      x: 150,
      y: 150,
    });
});
2 Views