【问题标题】:How to wait for pages with long load time to load in testcafe?如何等待加载时间长的页面加载到testcafe?
【发布时间】:2019-01-29 09:27:00
【问题描述】:

来自这些文档: https://devexpress.github.io/testcafe/documentation/test-api/actions/navigate.html

看起来我们只能等待 15 秒才能加载页面。

我们开发了一个 NextJS 应用程序,它的第一次加载需要 40 秒,因为它会在第一次加载时构建应用程序。

我似乎无法让 TestCafe 在初始页面加载时不超时。

我试过了

fixture('Restaurant List')
  .page('http://localhost:3000/something')
  .beforeEach(async () => {
    await waitForReact(120000);
  });

例如没有成功。

【问题讨论】:

    标签: testing automated-tests next.js e2e-testing testcafe


    【解决方案1】:

    您可以发送启动应用程序构建过程的第一个请求,并仅在收到响应时运行您的测试。

    请看下面的代码示例:

    const rp             = require('request-promise');
    const createTestCafe = require('testcafe');
    rp('https://site-url')
        .then(() => {       
             return createTestCafe('localhost', 1337, 1338);
        })   
        .then(testcafe => {
             runner = testcafe.createRunner();
    
             return runner
                 .src('tests');
                 .browsers('chrome');
        })
        .catch(err => console.log(err));
    

    【讨论】:

      【解决方案2】:

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-13
      • 2016-11-16
      • 1970-01-01
      相关资源
      最近更新 更多