Automated tests 如何在WebdriverIO中测量和报告执行时间?

Automated tests 如何在WebdriverIO中测量和报告执行时间?,automated-tests,performance-testing,webdriver-io,Automated Tests,Performance Testing,Webdriver Io,我想测量并报告某些元素在某个动作后出现在网页上的时间。大概是 describe('Load Time', () => { it('API Page', () => { browser.url('https://webdriver.io'); browser.$('=API').waitForDisplayed(); // measure time from here browser.$('=API').click(); browser.$(

我想测量并报告某些元素在某个动作后出现在网页上的时间。大概是

describe('Load Time', () => {
  it('API Page', () => {
    browser.url('https://webdriver.io');
    browser.$('=API').waitForDisplayed();
    // measure time from here
    browser.$('=API').click();
    browser.$('=Introduction').waitForDisplayed();
    // until here
  });
});
我尝试过的方法:

手动测量时间并将其写入控制台,如下所示:

describe('Load Time', () => {
  it('API Page', () => {
    browser.url('https://webdriver.io');
    browser.$('=API').waitForDisplayed();
    const start = process.hrtime();
    browser.$('=API').click();
    browser.$('=Introduction').waitForDisplayed();
    const elapsedhrtime = process.hrtime(start);
    const elapsedmilliseconds = (elapsedhrtime[1] / 1000000) + elapsedhrtime[0] * 1000;
    console.log(elapsedmilliseconds);
  });
});
然而,仅仅将其打印到控制台就很难对其进行解析以供以后分析,尤其是在有大量类似测试用例的情况下

我尝试的方法B:

使用JUnit reporter时,每个测试用例都有一个time属性。当然,它度量测试用例的整个执行时间。我的一个想法是这样做

describe('Load Time', () => {
  beforeAll(() => {
    browser.url('https://webdriver.io');
    browser.$('=API').waitForDisplayed();
  });

  it('API Page', () => {
    browser.$('=API').click();
    browser.$('=Introduction').waitForDisplayed();
  });
});
然后我在JUnit报告中只得到了相关的时间,但这只适用于beforeAll,而不适用于beforeach,因此我不能将多个测试用例放在一个套件中