首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Cypress中点击多个按钮,指定次数?

如何在Cypress中点击多个按钮,指定次数?
EN

Stack Overflow用户
提问于 2021-11-18 18:10:17
回答 0查看 88关注 0票数 1

我正在尝试编写一个测试,其中我需要检查博客列表是否按每个博客的点赞降序呈现。为此,我用Cypress创建了3个模拟博客,并想在测试它们是否按喜欢的降序排列之前,给它们一个特定的点赞数量(3 -1- 2)。然而,下面的代码给出了4-2-2赞,而不是预期的3-1- 2:

代码语言:javascript
复制
it('the blogs are ordered in descending order of likes', function() {

    cy.createBlog({
        title: 'The Perks of Being a Wallflower',
        author: 'Emma Watson',
        url: 'www.blank.org',
    })

    cy.createBlog({
        title: 'The Life of Pi',
        author: 'Yann Martel',
        url: 'www.pi.com',
    })

    cy.createBlog({
        title: 'Deep Dive into the World of Containers',
        author: 'GDG',
        url: 'www.gdg.com',
    })
    
    cy.wait(750)

    cy.contains('The Perks of Being a Wallflower')
    .contains('view').click({ multiple: true })
    .get('.blog-like-button').click({ multiple: true })
    
    cy.wait(750)

    cy.contains('The Perks of Being a Wallflower')
    .get('.blog-like-button').click({ multiple: true })

    cy.wait(750)

    cy.contains('The Perks of Being a Wallflower')
    .get('.blog-like-button').click({ multiple: true })
    cy.wait(750)

    cy.contains('The Life of Pi')
    .contains('view').click({ multiple: true })
    .get('.blog-like-button').click({ multiple: true })
    cy.wait(750)

    cy.contains('Deep Dive into the World of Containers')
    .contains('view').click({ multiple: true })
    .get('.blog-like-button').click({multiple: true})
    cy.wait(750)

    cy.contains('Deep Dive into the World of Containers')
    .get('.blog-like-button').click({ multiple: true })
    cy.wait(750)

    cy.reload()
})

Cypress中的错误输出如下所示:image of output of above code in Cypress

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70024720

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档