如何在使用testcafe运行测试之前单击按钮

问题描述 投票:3回答:2

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

目前,我的所有任务都因为无法传递页面而失败。

谢谢。

javascript automated-tests e2e-testing web-testing testcafe
2个回答
8
投票

你可以在BeforeEach Step中做到这一点


1
投票

代码看起来像这样:

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)
  })

它工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.