【问题标题】:Can't Click Start Button on Web App with Cypress使用 Cypress 无法在 Web 应用程序上单击开始按钮
【发布时间】:2020-08-22 17:08:38
【问题描述】:

学习 Cypress,在 Google 上找不到答案。这是按钮和周围元素的 html。我相信这个页面是一个带有 flex css 的 vue.js 网络应用程序。

<div class="row no-gutters align-center justify-center" data-v-11111111="">
    <div class="v-card__actions" data-v-11111111="">
        <button class="title v-btn--contained theme--dark v-size--x-large green"     data-v-11111111="" type="button">
            <span class="v-btn__content">
                Start
            </span>
        </button>
    </div>
</div>

这是我的赛普拉斯描述:

describe('Begin the form', () => {
    it('I can start the form', () => {
      cy.visit('https://this.app.com/#/start');
      cy.get("span[class='.v-btn__content']").click();
    });
  });

当我在 Cypress 中运行上述内容时,我在 Cypress 结果中得到以下结果:

Timed out retrying: Expected to find element: span[class='.v-btn__content'], but never found it.

【问题讨论】:

    标签: javascript vue.js flexbox automated-tests cypress


    【解决方案1】:

    cy.contains('Start').click();

    这应该解决这个问题

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    【解决方案2】:

    好的,然后试试这个

    cy.get('.v-btn--contained').click();
    

    【讨论】:

      【解决方案3】:

      你可以试试这个

      cy.get('.v-btn__content').click();
      

      如果它不起作用,请检查元素是否可见

      cy.get('.v-btn__content').should('be.visible');
      

      【讨论】:

      • 不,没什么。不过还是谢谢。
      猜你喜欢
      • 2019-07-27
      • 2021-10-15
      • 1970-01-01
      • 1970-01-01
      • 2012-05-04
      • 2017-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多