From 7ac14fb25309e597b554513270d87183ad73fd86 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 24 Oct 2022 17:54:27 +0300 Subject: [PATCH 1/3] fix: correctly convert JWP capabilities to W3C The `processConfig()` function attempts to convert capabilities from the deprecated JWP format to the new standard W3C one. Fix the logic for detecting when capabilites are in JWP format. (Previously, the logic was inverted.) Also, make sure that the `sauce:options` property is correctly populated in both cases. --- src/process-config.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/process-config.ts b/src/process-config.ts index 46578c1..17186e0 100644 --- a/src/process-config.ts +++ b/src/process-config.ts @@ -57,17 +57,19 @@ export function processConfig(config: any = {}, args: any = {}) { }; // transform JWP capabilities into W3C capabilities for backward compatibility - if (isW3C(args)) { + if (!isW3C(args)) { args.browserVersion = args.browserVersion || args.version || 'latest' args.platformName = args.platformName || args.platform || 'Windows 10' - args['sauce:options'] = {...capabilitiesFromConfig, ...(args['sauce:options'] || {})} // delete JWP capabilities delete args.version delete args.platform - } else { - args = {...args, ...capabilitiesFromConfig} } + + // Move capabilities from config into `sauce:options`. This is necessary for W3C. + // See: https://docs.saucelabs.com/dev/w3c-webdriver-capabilities/index.html#use-sauceoptions + args['sauce:options'] = {...capabilitiesFromConfig, ...(args['sauce:options'] || {})} + // Not needed delete args.base From 51f5c415729eafbc9788f0f4d9c3a5ee363dd581 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 24 Oct 2022 18:22:14 +0300 Subject: [PATCH 2/3] fix: do not convert IE9 from JWP to W3C Update the automatic conversion of capabilities from JWP to W3C format to exclude Internet Explorer 9. Although according to the [SauceLabs docs][1] all versions of Internet Explorer support the new W3C capabilities format, in reality only versions >=10 do. SauceLabs support has confirmed this and said that until the docs are fixed, _"the [Platform Configurator][2] would be the most reliable reference for compliant capabilities"_. Indeed, in the Platform Configurator, IE 9 only offers the option to select `JWP (legacy)` as the capabilities format. [1]: https://docs.saucelabs.com/dev/w3c-webdriver-capabilities/index.html#browser-compatibility [2]: https://saucelabs.com/platform/platform-configurator --- src/process-config.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/process-config.ts b/src/process-config.ts index 17186e0..10df10e 100644 --- a/src/process-config.ts +++ b/src/process-config.ts @@ -57,7 +57,9 @@ export function processConfig(config: any = {}, args: any = {}) { }; // transform JWP capabilities into W3C capabilities for backward compatibility - if (!isW3C(args)) { + // NOTE: IE9 is the only browser/version that supports **only** JWT. + const isIE9 = (args.browserName.toLowerCase() === 'internet explorer') && (args.version === '9'); + if (!isW3C(args) && !isIE9) { args.browserVersion = args.browserVersion || args.version || 'latest' args.platformName = args.platformName || args.platform || 'Windows 10' @@ -66,9 +68,16 @@ export function processConfig(config: any = {}, args: any = {}) { delete args.platform } - // Move capabilities from config into `sauce:options`. This is necessary for W3C. + // Move Sauce-specific options to the appropriate place inside capabilities. // See: https://docs.saucelabs.com/dev/w3c-webdriver-capabilities/index.html#use-sauceoptions - args['sauce:options'] = {...capabilitiesFromConfig, ...(args['sauce:options'] || {})} + if (isIE9) { + // In JWT format (which IE9 has to use), Sauce-specific options need to be added to the + // top-level capabilities. + args = {...args, ...capabilitiesFromConfig} + } else { + // In W3C format, Sauce-specific options need to be put inside `sauce:options`. + args['sauce:options'] = {...capabilitiesFromConfig, ...(args['sauce:options'] || {})} + } // Not needed delete args.base From a00e886235dcdb5f5a32c3ec878a3aceeda5492f Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 24 Oct 2022 18:56:59 +0300 Subject: [PATCH 3/3] fix: use `appium:platformVersion` in `browserName` (if present) Use the value of `appium:platformVersion` (if present) in `browserName`. Since the [capabilities config when using Appium][1] does not include a browser version, but only the platform version, including the value of `appium:platformVersion` in `browserName` is essential in order to be able to identify which platform the logs refer to. [1]: https://docs.saucelabs.com/mobile-apps/automated-testing/appium/virtual-devices/#ios-code-examples --- src/process-config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/process-config.ts b/src/process-config.ts index 10df10e..4938fc3 100644 --- a/src/process-config.ts +++ b/src/process-config.ts @@ -21,7 +21,9 @@ export function processConfig(config: any = {}, args: any = {}) { } // Browser name that will be printed out by Karma. - const browserName = `${args.browserName} ${args.browserVersion || args.version || ''} ${args.platformName || args.platform || ''}`; + const browserName = + `${args.browserName} ${args.browserVersion || args.version || ''} ` + + `${args.platformName || args.platform || ''} ${args['appium:platformVersion'] || ''}`.trim(); // In case "startConnect" is enabled, and no tunnel identifier has been specified, we just // generate one randomly. This makes it possible for developers to use "startConnect" with