小编Sam*_*alg的帖子

有没有办法访问剪贴板内容?

我正在测试一个页面,该页面具有一个带有嵌入代码的文本框和一个“复制”按钮,该按钮应该将文本框的内容复制到剪贴板上,以便用户可以将其粘贴到其他地方。有没有办法测试单击“复制”按钮并验证剪贴板内容是否与文本框的内容匹配?谢谢!

clipboard automated-tests e2e-testing testcafe

7
推荐指数
1
解决办法
2466
查看次数

页面对象方法?

我在设置页面对象时遇到问题。这可能是一个简单的语法问题,但我一直无法找到解决方案。我正在尝试做这样的事情:

测试:

test('Verify that a user can update their billing profile', async (t) => {
  await t
    .billingPage.enterBillingInformation('4111111111111111')
    .click(billingPage.saveButton)
    .expect(billingPage.successMessage.exists).ok();
});
Run Code Online (Sandbox Code Playgroud)

页:

import { Selector, t } from 'testcafe';

export default class billingPage {
  constructor() {
    this.cardNameInput = Selector('#cc_name');
    this.cardNumberInput = Selector('#credit-card-number');
    this.saveButton = Selector('button').withText('Save Card');
    this.successMessage = Selector('div').withText('Your billing information has been successfully updated.');
  }

  async enterBillingInformation(cardNum) {
    await t
      .typeText(this.cardNameInput, 'Foo Bar')
      .typeText(this.cardNumberInput, cardNum)
  }
}
Run Code Online (Sandbox Code Playgroud)

当我在测试中拥有所有函数内容时,这是有效的,但我想用无效的凭据编写第二个测试,而且,obvs,我想重用代码(实际函数更长,有更多字段)。但我无法弄清楚我做错了什么。

我收到此错误:

TypeError: Cannot read property 'enterBillingInformation' of undefined
Run Code Online (Sandbox Code Playgroud)

文档中有关如何在页面对象中使用方法的示例将非常有帮助!这个页面似乎展示了如何设置该功能,但没有相应的代码片段来展示如何在测试中实际使用它。

http://devexpress.github.io/testcafe/documentation/test-api/test-code-structure.html#test-controller

javascript testing automated-tests e2e-testing testcafe

5
推荐指数
1
解决办法
576
查看次数

Testcafe并发引发奇怪的错误

我有一套测试,当没有并发运行时,所有测试都可以通过。当我开始并发运行它们时,它们开始崩溃。我不认为测试之间存在相互依赖关系,这会使它们失败。如果测试失败,则如下所示:

1) A JavaScript error occurred on
  "https://advancedaccount.wistia.io/stats/medias/lz45f2dspl#social".
     Repeat test actions in the browser and check the console for errors.
     If you see this error, it means that the tested website caused it. You can fix it or disable tracking JavaScript errors in TestCafe. To do the latter, enable the
  "--skip-js-errors" option.
     If this error does not occur, please write a new issue at:
     "https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md".

     JavaScript error details:
     undefined:
         No stack trace available

     Browser: Chrome 73.0.3683 / Linux 0.0.0
     Screenshot: …
Run Code Online (Sandbox Code Playgroud)

concurrency automated-tests web-testing e2e-testing testcafe

5
推荐指数
0
解决办法
216
查看次数