【问题标题】:Dragging point does not work and throws no error拖动点不起作用并且不会引发错误
【发布时间】:2019-11-08 15:10:27
【问题描述】:

我是测试和柏树的新手。我正在对裁剪图像的工具进行自动化测试,但我遇到了一个无法解决的问题。

Here is screenshot of the tool

所以我这个工具拖一点的代码是这样的,但是不行。

        cy.get('.point-w').trigger('mousedown',)
        .trigger('mousemove', { clientX: 5, clientY:0})
        .trigger('mouseup', {force : true})

不要抛出任何错误,但点不会移动。如果我检查触发器('mousedown')的快照,它似乎点击了那里。 Look the point.

谢谢大家! :D

【问题讨论】:

    标签: testing automated-tests cypress


    【解决方案1】:

    拖放具有针对不同框架的各种实现。
    在我们的例子中,移动事件仅适用于元素本身的触发事件,并继续从body 移动到目标坐标:

    const SLOPPY_CLICK_THRESHOLD = 10;
        cy.get('.point-w').then(subject => {
            const coordsDrag = subject[0].getBoundingClientRect();
            cy.wrap(subject)
                .trigger('mousedown', {
                    clientX: coordsDrag.x,
                    clientY: coordsDrag.y,
                    force: true
                })
                .trigger('mousemove', {
                    clientX: coordsDrag.x + SLOPPY_CLICK_THRESHOLD,
                    clientY: coordsDrag.y,
                    force: true
                });
            cy.get('body')
                .trigger('mousemove', { 
                    clientX: 5, 
                    clientY: 0, 
                    force: true 
                 })
                .trigger('mouseup');
        });
    

    【讨论】:

    • 我试过了,但是好像真的不行。
    猜你喜欢
    • 1970-01-01
    • 2021-01-11
    • 2020-07-20
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    • 2017-02-06
    • 2021-01-02
    相关资源
    最近更新 更多