【问题标题】:in Cypress find total number of elements and log在赛普拉斯中找到元素总数和日志
【发布时间】:2019-12-02 16:06:00
【问题描述】:

IN Cypress 我怎样才能找到Listbox 中存在的元素总数

我如何记录它?

cy.get(element)as(alias)

initiacount= cy.get(@alias).length;

cy.log(initialcount)

【问题讨论】:

    标签: cypress


    【解决方案1】:

    你可以试试下面的方法。

      cy.get('element').then((elem)=>{
          const listingCount = Cypress.$(elem).length;
          console.log("List of Counts:"+listingCount);
           //or 
          cy.log(listingCount);
        })
    

    在你的情况下,我假设如果这是正常的list box or a drop down box,可以尝试以下方式:

    cy.get('select > option').then((option)=>{
              const listingCount = Cypress.$(option).length;
              console.log("List of Counts:"+listingCount);
               //or 
              cy.log(listingCount);
            })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-23
      • 1970-01-01
      • 2021-03-27
      • 2022-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多