How to use @wdio/devtools-service - 2 common examples

To help you get started, we’ve selected a few @wdio/devtools-service examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oxygenhq / oxygen / src / ox_services / service-devtools.js View on Github external
async onModuleInitialized(module) {
        // skip any module that does not implement .getDriver() method (e.g. not webdriver based)
        if (!module || !module.getDriver || typeof module.getDriver !== 'function' || !module.getCapabilities || typeof module.getCapabilities !== 'function') {
            return;
        }
        const submodule = this._subModules[module.name];
        if (!submodule) {
            return;
        }
        // initialize DevToolsService and hook it to the current webdriver object
        const devToolsSvc = new WDIODevToolsService();
        devToolsSvc.beforeSession(null, module.getCapabilities());
        if (devToolsSvc.isSupported) {
            // change global.browser to the current module's webdriver instance
            const orgGlobalBrowser = global.browser;
            global.browser = module.getDriver();
            await devToolsSvc.before();
            submodule.init(devToolsSvc);
            global.browser = orgGlobalBrowser;
        }
    }
    onModuleWillDispose(module) {
github oxygenhq / oxygen / ox_modules / module-web.js View on Github external
isInitialized = true;
            }))
            .catch(err => {
                initError = err;
            });

        deasync.loopWhile(() => !isInitialized && !initError);

        if (initError) {
            throw _this.errHelper.getSeleniumInitError(initError);
        }

        _this.driver.setTimeout({ 'implicit': _this.waitForTimeout });

        // initialize DevTools service. this is used to collect network requests
        var devTools = new DevToolsService();
        devTools.beforeSession(null, _this.driver.capabilities);
        if (devTools.isSupported) {
            // prevent devtools-service from generating logs
            // this should be done in a different, more proper, way, but for now just init the logger used by devtools-service:CommandHandler
            // so it cannot be inited by the service itself.
            WDIOLogger('@wdio/devtools-service:CommandHandler');
            global.browser = _this.driver;
            devTools.before();
            _this.driver.on('Network.responseReceived', (params) => {
                if (_this.networkCollect) {
                    _this.networkRequests.push(params.response);
                }
            });
        }

        // reset browser logs if auto collect logs option is enabled

@wdio/devtools-service

A WebdriverIO service that allows you to run Chrome DevTools commands in your tests

MIT
Latest version published 7 days ago

Package Health Score

89 / 100
Full package analysis

Popular @wdio/devtools-service functions