diff --git a/protractor/utils.js b/protractor/utils.js index c3a2591..fb6b030 100644 --- a/protractor/utils.js +++ b/protractor/utils.js @@ -115,31 +115,35 @@ function replaceCommands (prtrctrCommand) { } } +function parseSeleniumAddress (value) { + const u = url.parse(value) + remoteHostname = u.hostname + return [ + this.objectProperty( + this.identifier('protocol'), + this.stringLiteral(u.protocol.slice(0, -1)) + ), + this.objectProperty( + this.identifier('hostname'), + this.stringLiteral(u.hostname) + ), + this.objectProperty( + this.identifier('port'), + this.literal(parseInt(u.port || '443')) + ), + this.objectProperty( + this.identifier('path'), + this.stringLiteral(u.path) + ) + ] +} + let remoteHostname = null function parseConfigProperties (property) { const name = property.key.name || property.key.value const value = property.value.value if (name === 'seleniumAddress') { - const u = url.parse(value) - remoteHostname = u.hostname - return [ - this.objectProperty( - this.identifier('protocol'), - this.stringLiteral(u.protocol.slice(0, -1)) - ), - this.objectProperty( - this.identifier('hostname'), - this.stringLiteral(u.hostname) - ), - this.objectProperty( - this.identifier('port'), - this.literal(parseInt(u.port)) - ), - this.objectProperty( - this.identifier('path'), - this.stringLiteral(u.path) - ) - ] + return parseSeleniumAddress.call(this, value) } else if (name === 'capabilities') { const { rootLevelConfigs, parsedCaps } = parseCapabilities.call(this, property.value.properties) return [ @@ -161,9 +165,7 @@ function parseCapabilities (caps) { for (const cap of caps) { const name = cap.key.name || cap.key.value if (name === 'name') { - console.log('DOO WE', remoteHostname); if (!remoteHostname || (!remoteHostname.includes('browserstack') && !remoteHostname.includes('saucelabs'))) { - console.log('AHH'); continue } parsedCaps.push( @@ -177,6 +179,8 @@ function parseCapabilities (caps) { ]) ) ) + } else if (name === 'seleniumAddress') { + parsedCaps.push(...parseSeleniumAddress.call(this, cap.value.value)) } else { parsedCaps.push(cap) } diff --git a/test/__fixtures__/protractor/source/conf.js b/test/__fixtures__/protractor/source/conf.js index 249dda9..71ede24 100644 --- a/test/__fixtures__/protractor/source/conf.js +++ b/test/__fixtures__/protractor/source/conf.js @@ -1,9 +1,10 @@ // Tests for the calculator. exports.config = { - seleniumAddress: 'https://ondemand.saucelabs.com:4444/wd/hub', + seleniumAddress: 'https://ondemand.saucelabs.com/wd/hub', capabilities: { 'browserName': 'chrome', - name: 'foobar' + name: 'foobar', + seleniumAddress: 'http://localhost:4444/wd/hub' }, specs: [ 'spec.js' diff --git a/test/__fixtures__/protractor/transformed/conf.js b/test/__fixtures__/protractor/transformed/conf.js index bb2f795..b76e656 100644 --- a/test/__fixtures__/protractor/transformed/conf.js +++ b/test/__fixtures__/protractor/transformed/conf.js @@ -1,7 +1,7 @@ exports.config = { protocol: "https", hostname: "ondemand.saucelabs.com", - port: 4444, + port: 443, path: "/wd/hub", capabilities: [{ @@ -9,7 +9,12 @@ exports.config = { "sauce:options": { name: "foobar" - } + }, + + protocol: "http", + hostname: "localhost", + port: 4444, + path: "/wd/hub" }], specs: [