Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

422
Vistas
Cypress: resizing / dragging elements

I am trying to resize a box element by clicking on the bottom right corner and dragging it down a few pixels. Example what I have but does not work:

    it("tests resizing elements", () => {
        cy.findByText(/zoom/i)
            .nextAll(1)
            .invoke("text")
            .then(($text) => {
                let zoom = parseInt($text.split("%")[0]);
                let objects;
                cy.window()
                    .then(($win) => {
                        objects = $win.canvas.getObjects();
                    })
                    .then(() => {
                        cy.getSidebarButton("Edit mode").click();
                        // x and y are relative to the zoom percentage
                        let x =
                            ((objects[objects.length - 1].left +
                                objects[objects.length - 1].width) /
                                100) * zoom;
                        let y =
                            ((objects[objects.length - 1].top +
                                objects[objects.length - 1].height) /
                                100) * zoom;
                        cy.getCanvas()
                            .trigger("mousedown", x, y)
                            .trigger("mousemove", x + 20, y + 25)
                            .trigger("mouseup", x + 20, y + 25);
                    });
            });
    });

What the code currently does is click on the correct spot, drag the object and then release, but it moves the object instead of resizing it.

Any help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try triggering resize directly:

cy.getCanvas().trigger('resize',x,y);
about 4 years ago · Juan Pablo Isaza Denunciar

0

Finally figured what I needed. The issue was that the element needed to be clicked. So replacing the last bit of my code with

                        cy.getCanvas()
                            .trigger("mousedown", x, y)
                            .trigger("mouseup", x, y)
                            .trigger("mousedown", x, y)
                            .trigger("mousemove", x + 50, y + 55)
                            .trigger("mouseup", x + 50, y + 55);

fixed my issue. (To my surprise, .click() was not enough and it had to be mousedown and mouseup.)

What helped me realize this was needed was spying on the events fired when doing it manually.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda