webdriverio: Devtools performance example tests is not working

session.off is not a function error when trying to capture performance via devtools:

Environment (please complete the following information):

  • WebdriverIO version: 5.9.6
  • Mode: WDIO Testrunner
  • **If WDIO Testrunner, running sync/async: sync
  • Node.js version: [8.10
  • NPM version: [e.g. 5.8.0]
  • Browser name and version: chrome Version 74.0.3729.169
  • **Platform name and version:**OSX
  • Additional wdio packages used (if applicable): @wdio/devtools-service, chromdriver Config of WebdriverIO An example of how you configured WebdriverIO config

Describe the bug Following the example at: https://webdriver.io/docs/devtools-service.html#access-puppeteer-instance produces an error :

session.off is not a function
[chrome  mac os x #0-0] TypeError: session.off is not a function
[chrome  mac os x #0-0]     at cancel (/Users/pmerwin/Projects/qa/WDIO-5/lib-webdriverio-nodejs-v2/node_modules/@wdio/devtools-service/build/gatherer/trace.js:341:17)

To Reproduce Steps to reproduce the behavior: config:

const merge = require('deepmerge');
const wdioBaseConf = require('./base');
exports.config = merge(wdioBaseConf.config, {
    capabilities: [{
        browserName: 'chrome',
        platformName: 'MAC',
        'goog:chromeOptions': {
            w3c: true
        }
    }],
    port: 9515,
    path: '/',
    // ...
    services: ['chromedriver', 'devtools'], // wdio, set this in package.json for chromedriver
    mochaOpts: {
        ui: 'bdd',
        compilers: ['js:@babel/register'],
        timeout: 120000,
        bail: true
    },
    reporters: ['spec']
});

with spec:

const assert = require('assert');

describe('JSON.org page', () => {
    before(() => {
        browser.enablePerformanceAudits();
    });

    it('should load within performance budget', () => {
        browser.url('http://json.org');

        let metrics = browser.getMetrics();
        assert.ok(metrics.speedIndex < 1500); // check that speedIndex is below 1.5ms

        let score = browser.getPerformanceScore(); // get Lighthouse Performance score
        assert.ok(score >= 0.99); // Lighthouse Performance score is at 99% or higher

        $('=Esperanto').click();

        metrics = browser.getMetrics();
        assert.ok(metrics.speedIndex < 1500);
        score = browser.getPerformanceScore();
        assert.ok(score >= 0.99);
    });

    after(() => {
        browser.disablePerformanceAudits();
    });
});

Expected behavior Test should run and deliver metrcis data but fails with an error

Log

2019-06-04T18:06:46.657Z INFO @wdio/local-runner: Run worker command: run
2019-06-04T18:06:46.960Z INFO webdriver: [POST] http://127.0.0.1:9515/session
2019-06-04T18:06:46.960Z INFO webdriver: DATA { capabilities: 
   { alwaysMatch: 
      { browserName: 'chrome',
        platformName: 'MAC',
        'goog:chromeOptions': [Object] },
     firstMatch: [ {} ] },
  desiredCapabilities: 
   { browserName: 'chrome',
     platformName: 'MAC',
     'goog:chromeOptions': { w3c: true } } }
2019-06-04T18:06:48.669Z INFO @wdio/devtools-service:DevToolsDriver: Connect to http://localhost:55949
2019-06-04T18:06:48.715Z INFO @wdio/devtools-service: Connected to Chrome on localhost:55949
2019-06-04T18:06:49.275Z INFO webdriver: COMMAND enablePerformanceAudits()
2019-06-04T18:06:49.278Z INFO webdriver: RESULT undefined
2019-06-04T18:06:49.282Z INFO @wdio/devtools-service:TraceGatherer: Start tracing frame with url http://json.org/
2019-06-04T18:06:49.390Z INFO @wdio/devtools-service:TraceGatherer: Waiting for CPU to become idle
2019-06-04T18:06:49.400Z INFO webdriver: COMMAND navigateTo("http://json.org/")
2019-06-04T18:06:49.401Z INFO webdriver: [POST] http://127.0.0.1:9515/session/673ea9b7b70adce4e662780c094bd4e7/url
2019-06-04T18:06:49.401Z INFO webdriver: DATA { url: 'http://json.org/' }
2019-06-04T18:06:49.527Z INFO @wdio/devtools-service:TraceGatherer: Ignore navigated frame with url about:blank
2019-06-04T18:06:49.863Z INFO @wdio/devtools-service:TraceGatherer: Driver CPU has been idle for 0 ms
2019-06-04T18:06:49.863Z INFO @wdio/devtools-service:TraceGatherer: Driver CPU has been idle for 0 ms
2019-06-04T18:06:49.875Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.704Z INFO @wdio/devtools-service:TraceGatherer: Page load detected: http://json.org/, set frameId 5220C4EB6EB7F7B4A95EB13D9177CC1D, set loaderId A8D058D89051AD1221679060CAAE9D48
2019-06-04T18:06:50.705Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.713Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.713Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.713Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.714Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.714Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.714Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.714Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.714Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.715Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:50.715Z INFO @wdio/devtools-service:TraceGatherer: Waiting on DomContentLoaded
2019-06-04T18:06:51.654Z INFO @wdio/devtools-service:TraceGatherer: Found 5 inflight network records
2019-06-04T18:06:51.654Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/img/json160.gif to finish
2019-06-04T18:06:51.654Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/object.gif to finish
2019-06-04T18:06:51.654Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/value.gif to finish
2019-06-04T18:06:51.654Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/string.gif to finish
2019-06-04T18:06:51.654Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/number.gif to finish
2019-06-04T18:06:51.655Z INFO @wdio/devtools-service:TraceGatherer: Found 5 inflight network records
2019-06-04T18:06:51.655Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/img/json160.gif to finish
2019-06-04T18:06:51.655Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/object.gif to finish
2019-06-04T18:06:51.655Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/value.gif to finish
2019-06-04T18:06:51.655Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/string.gif to finish
2019-06-04T18:06:51.655Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/number.gif to finish
2019-06-04T18:06:51.686Z INFO @wdio/devtools-service:TraceGatherer: Found 4 inflight network records
2019-06-04T18:06:51.686Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/img/json160.gif to finish
2019-06-04T18:06:51.686Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/value.gif to finish
2019-06-04T18:06:51.686Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/string.gif to finish
2019-06-04T18:06:51.687Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/number.gif to finish
2019-06-04T18:06:51.687Z INFO @wdio/devtools-service:TraceGatherer: Found 4 inflight network records
2019-06-04T18:06:51.687Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/img/json160.gif to finish
2019-06-04T18:06:51.687Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/value.gif to finish
2019-06-04T18:06:51.687Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/string.gif to finish
2019-06-04T18:06:51.687Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/number.gif to finish
2019-06-04T18:06:51.725Z INFO @wdio/devtools-service:TraceGatherer: Found 3 inflight network records
2019-06-04T18:06:51.725Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/img/json160.gif to finish
2019-06-04T18:06:51.725Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/string.gif to finish
2019-06-04T18:06:51.725Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/number.gif to finish
2019-06-04T18:06:51.726Z INFO @wdio/devtools-service:TraceGatherer: Found 3 inflight network records
2019-06-04T18:06:51.726Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/img/json160.gif to finish
2019-06-04T18:06:51.726Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/string.gif to finish
2019-06-04T18:06:51.726Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/number.gif to finish
2019-06-04T18:06:51.791Z INFO @wdio/devtools-service:TraceGatherer: Found 2 inflight network records
2019-06-04T18:06:51.792Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/img/json160.gif to finish
2019-06-04T18:06:51.792Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/string.gif to finish
2019-06-04T18:06:51.813Z INFO @wdio/devtools-service:TraceGatherer: Found 1 inflight network records
2019-06-04T18:06:51.813Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/string.gif to finish
2019-06-04T18:06:51.843Z INFO @wdio/devtools-service:TraceGatherer: Found 0 inflight network records
2019-06-04T18:06:51.850Z INFO @wdio/devtools-service:TraceGatherer: Found 1 inflight network records
2019-06-04T18:06:51.851Z INFO @wdio/devtools-service:TraceGatherer: Waiting on https://www.json.org/favicon.gif to finish
2019-06-04T18:06:51.852Z INFO @wdio/devtools-service: Wait until tracing for command navigateTo finishes
2019-06-04T18:06:52.418Z INFO @wdio/devtools-service:TraceGatherer: Found 0 inflight network records
2019-06-04T18:06:56.794Z INFO @wdio/devtools-service:TraceGatherer: Network became finally idle
2019-06-04T18:06:56.794Z INFO @wdio/devtools-service:TraceGatherer: Wait for network idle canceled
2019-06-04T18:06:56.801Z INFO webdriver: COMMAND takeScreenshot()
2019-06-04T18:06:56.801Z INFO webdriver: [GET] http://127.0.0.1:9515/session/673ea9b7b70adce4e662780c094bd4e7/screenshot
2019-06-04T18:06:57.141Z INFO webdriver: RESULT iVBORw0KGgoAAAANSUhEUgAABLAAAARSCAYAAACwrQlGAAAAAXNSR0IArs4c6...
2019-06-04T18:06:57.144Z INFO webdriver: COMMAND disablePerformanceAudits()
2019-06-04T18:06:57.144Z INFO webdriver: RESULT undefined
2019-06-04T18:06:57.186Z INFO webdriver: COMMAND deleteSession()
2019-06-04T18:06:57.187Z INFO webdriver: [DELETE] http://127.0.0.1:9515/session/673ea9b7b70adce4e662780c094bd4e7

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (15 by maintainers)

Most upvoted comments

+ @wdio/cli@5.10.7
+ @wdio/devtools-service@5.10.6
+ @wdio/local-runner@5.10.7
+ webdriverio@5.10.7
+ wdio-chromedriver-service@5.0.2

ran npm update nuked node_modules, did npm install … looks fixed 😃 . Thanks!