From 1209084a60f0af6d8aeb47de4407e7773da6addd Mon Sep 17 00:00:00 2001 From: amit3200 Date: Thu, 14 Sep 2023 00:13:27 +0530 Subject: [PATCH 1/2] Check if deviceName was passed --- packages/webdriver-utils/src/metadata/metaDataResolver.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/webdriver-utils/src/metadata/metaDataResolver.js b/packages/webdriver-utils/src/metadata/metaDataResolver.js index fd3b51824..a62f11e00 100644 --- a/packages/webdriver-utils/src/metadata/metaDataResolver.js +++ b/packages/webdriver-utils/src/metadata/metaDataResolver.js @@ -8,7 +8,8 @@ export default class MetaDataResolver { const platform = opts.platformName || opts.platform; if (['ios', 'android'].includes(platform.toLowerCase()) || ['ios', 'android'].includes(capabilities?.platformName?.toLowerCase()) || - ['ipad', 'iphone'].includes(capabilities?.device?.toString()?.toLowerCase())) { + ['ipad', 'iphone'].includes(capabilities?.device?.toString()?.toLowerCase()) || + opts?.deviceName !== undefined) { return new MobileMetaData(driver, capabilities); } else { return new DesktopMetaData(driver, capabilities); From 9eda3e4ab706fa8d11aa70415ccfee723a389183 Mon Sep 17 00:00:00 2001 From: amit3200 Date: Thu, 14 Sep 2023 16:16:33 +0530 Subject: [PATCH 2/2] Updating Tests --- .../test/metadata/metaDataResolver.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/webdriver-utils/test/metadata/metaDataResolver.test.js b/packages/webdriver-utils/test/metadata/metaDataResolver.test.js index 040792439..23a3edddb 100644 --- a/packages/webdriver-utils/test/metadata/metaDataResolver.test.js +++ b/packages/webdriver-utils/test/metadata/metaDataResolver.test.js @@ -32,5 +32,19 @@ describe('MetaDataResolver', () => { expect(metadata.driver).toEqual(driver); expect(metadata.capabilities).toEqual({}); }); + + it('resolves MobileMetaData when deviceName is passed', () => { + metadata = MetaDataResolver.resolve(driver, capabilities, { platform: 'Linux', deviceName: 'RX224' }); + expect(metadata).toBeInstanceOf(MobileMetaData); + expect(metadata.driver).toEqual(driver); + expect(metadata.capabilities).toEqual({}); + }); + + it('resolves DesktopMetaData when no deviceName is passed', () => { + metadata = MetaDataResolver.resolve(driver, capabilities, { platform: 'Linux' }); + expect(metadata).toBeInstanceOf(DesktopMetaData); + expect(metadata.driver).toEqual(driver); + expect(metadata.capabilities).toEqual({}); + }); }); });