【问题标题】:How to click a button before running tests with testcafe如何在使用 testcafe 运行测试之前单击按钮
【发布时间】:2019-04-02 15:19:42
【问题描述】:

我想测试我的网站应用程序的页面。但是,在您访问实际应用程序之前,我需要接受一个免责声明页面。在进行测试之前有没有办法执行任务(在我的情况下单击接受按钮)。

目前,我的所有任务都失败了,因为它们无法通过页面。

谢谢。

【问题讨论】:

    标签: javascript automated-tests e2e-testing web-testing testcafe


    【解决方案1】:

    您可以在BeforeEach 步骤中执行此操作

    【讨论】:

      【解决方案2】:

      代码如下所示:

      fixture`testing BeforeEach functionality`
        .meta('fixtureID', 'fix-0001')
        .meta({ author: 'luka98v', creationDate: Date() })
        .page`${url}`
        .beforeEach(async t => {
          const acceptButton = Selector('#accept-disclaimer')
          await t
            .click(acceptButton)
        })
      

      效果很好。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-06-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-08
        相关资源
        最近更新 更多