diff --git a/lib/index.js b/lib/index.js index c508559679..783ae769de 100644 --- a/lib/index.js +++ b/lib/index.js @@ -137,7 +137,13 @@ module.exports.createClient = function({ .then(() => { return client.createSession({argv}); }) - .then(_ => { + .then((data) => { + if (this.settings.test_runner?.type === 'cucumber' && NightwatchEventHub.isAvailable) { + const NightwatchFormatter = require('./runner/test-runners/cucumber/nightwatch-format'); + + NightwatchFormatter.setCapabilities(data); + } + return client.api; }) .catch((error) => { diff --git a/lib/transport/selenium-webdriver/index.js b/lib/transport/selenium-webdriver/index.js index e06eea3f13..8eb9177437 100644 --- a/lib/transport/selenium-webdriver/index.js +++ b/lib/transport/selenium-webdriver/index.js @@ -12,7 +12,6 @@ const CDP = require('./cdp.js'); const {colors} = Logger; const {isErrorResponse, checkLegacyResponse, throwDecodedError, WebDriverError} = error; const {IosSessionErrors} = require('../errors'); -const {NightwatchEventHub} = require('../../runner/eventHub.js'); let _driverService = null; let _driver = null; @@ -298,20 +297,11 @@ class Transport extends BaseTransport { this.__elementKey = elementKey; await this.showConnectInfo({startTime, host, port, start_process, sessionInfo}); - if (this.settings.test_runner?.type === 'cucumber' && NightwatchEventHub.isAvailable) { - const NightwatchFormatter = require('../../runner/test-runners/cucumber/nightwatch-format.js'); - - NightwatchFormatter.setCapabilities({ - sessionId, - capabilities, - host, - port - }); - } - return { sessionId, - capabilities + capabilities, + host, + port }; } catch (err) { const error = this.handleConnectError(err);