简体   繁体   English

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

[英]How to click a button before running tests with testcafe

I want to test the pages of my website application. 我想测试我的网站应用程序的页面。 However, I have a disclaimer page that needs to be accepted before you can access the actual application. 但是,在您访问实际应用程序之前,我有一个需要接受的免责声明页面。 Is there a way to execute a task (click the accept button in my case) before doing the tests. 有没有办法在执行测试之前执行任务(在我的情况下单击“接受”按钮)。

Currently, all my tasks fail because they can't pass the page. 目前,我的所有任务都因为无法传递页面而失败。

Thanks. 谢谢。

您可以在BeforeEach Step中执行此操作

The code will look something like this: 代码看起来像这样:

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

It works fine. 它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM