首页 > 解决方案 > 使用 Cypress 无法在 Web 应用程序上单击开始按钮

问题描述

学习 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.

标签: javascriptvue.jsflexboxautomated-testscypress

解决方案


好的,然后试试这个

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

推荐阅读