From 2a6cdbe7604e9035328254259b52d5827b917836 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Fri, 28 Jun 2024 11:36:10 -0700 Subject: [PATCH] fix: add mini browser version for non browser info case (#641) --- packages/appium-tizen-tv-driver/lib/driver.js | 9 ++++++--- .../test/unit/driver.spec.js | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/appium-tizen-tv-driver/lib/driver.js b/packages/appium-tizen-tv-driver/lib/driver.js index 33a9e2f8..29e6a755 100644 --- a/packages/appium-tizen-tv-driver/lib/driver.js +++ b/packages/appium-tizen-tv-driver/lib/driver.js @@ -503,9 +503,10 @@ class TizenTVDriver extends BaseDriver { /** * Set chrome version v63.0.3239.0 as the minimal version - * for autodownload to use proper chromedriver version. - * Older than the chromedriver version could raise no Chrome binary found error, - * which no makes sense for TV automation usage. + * for autodownload to use proper chromedriver version if + * - the 'Browser' info does not have proper chrome version, or + * - older than the chromedriver version could raise no Chrome binary found error, + * which no makes sense for TV automation usage. * * @param {BrowserVersionInfo} browserVersionInfo * @return {BrowserVersionInfo} @@ -513,6 +514,7 @@ class TizenTVDriver extends BaseDriver { fixChromeVersionForAutodownload(browserVersionInfo) { const chromeVersion = VERSION_PATTERN.exec(browserVersionInfo.Browser ?? ''); if (!chromeVersion) { + browserVersionInfo.Browser = MIN_CHROME_VERSION; return browserVersionInfo; } @@ -542,6 +544,7 @@ class TizenTVDriver extends BaseDriver { result = await got.get(`http://${debuggerAddress}/json/version`).json(); log.info(`The response of http://${debuggerAddress}/json/version was ${JSON.stringify(result)}`); result = this.fixChromeVersionForAutodownload(result); + log.info(`Fixed browser info is ${JSON.stringify(result)}`); // To respect the executableDir. executable = undefined; } catch (err) { diff --git a/packages/appium-tizen-tv-driver/test/unit/driver.spec.js b/packages/appium-tizen-tv-driver/test/unit/driver.spec.js index 5b05841e..8693654c 100644 --- a/packages/appium-tizen-tv-driver/test/unit/driver.spec.js +++ b/packages/appium-tizen-tv-driver/test/unit/driver.spec.js @@ -107,6 +107,25 @@ describe('TizenTVDriver', function () { ); }); + it('Set minimal chrome version with no browser', function () { + const browserInfo = { + 'Browser': '', + 'Protocol-Version': '1.2', + 'User-Agent': 'Mozilla/5.0 (SMART-TV; LINUX; Tizen 4.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 TV Safari/537.36', + 'WebKit-Version': '537.36 (@24d4006dbb9188e920764a35a60873d6a0157c12)' + }; + expect( + driver.fixChromeVersionForAutodownload(browserInfo), + 'to equal', + { + 'Browser': 'Chrome/63.0.3239.0', + 'Protocol-Version': '1.2', + 'User-Agent': 'Mozilla/5.0 (SMART-TV; LINUX; Tizen 4.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 TV Safari/537.36', + 'WebKit-Version': '537.36 (@24d4006dbb9188e920764a35a60873d6a0157c12)' + } + ); + }); + it('Use the given chrome version', function () { const browserInfo = { 'Browser': 'Chrome/63.0.3239.0',