【问题标题】:How to find which variable is greater with cypress如何使用柏树找到哪个变量更大
【发布时间】:2019-09-13 11:53:28
【问题描述】:

请帮助我。 我有 2 个变量,想知道柏树的哪个变量更大。 像这样:

if(rejectedCount > sortedCount){
    return true
} else return false

是否有任何断言。

这是我的代码

cy.get('.list-table-list-item').eq(0)

.find('.reject span')
.invoke('text')
.then(text => {
     const rejectedCount = text;
     cy.get('.sortingReject').click();
     cy.get('.list-table-list-item').eq(0)
         .find('.reject span')
         .invoke('text')
         .then(text => {
              const sortedCount = text;
             // There should be my assertion Like this
              cy.get(sortedCount).should('be.gt', rejectedCount);

           });
  });

但它不能正常工作。 请帮帮我!

【问题讨论】:

  • 我找到了答案。这是正确的断言... assert.isAbove(sortedCount, deniedCount)

标签: sorting automated-tests e2e-testing cypress


【解决方案1】:

你应该使用expect

expect(sortedCount).to.be.gt(rejectedCount)

https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Explicit-Subjects

【讨论】:

  • 我正在使用 assert.isAbove(sortedCount, firstCount) 但您的回答也很有效,谢谢
猜你喜欢
  • 2019-02-03
  • 2021-01-27
  • 1970-01-01
  • 2021-01-14
  • 2021-08-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-09
相关资源
最近更新 更多