0

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!

demouser123
  • 4,108
  • 9
  • 50
  • 82
Luca
  • 335
  • 3
  • 19

1 Answers1

0

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,
     });
 });
Luca
  • 335
  • 3
  • 19
  • 3
    To clarify your answer, you were using the wrong `window` in the original test. Cypress provides access to the app's window via `cy.window()`. – Eddy Gilmour Sep 29 '21 at 07:37