From 3ea931a1f6bf1c35894f1dc489a3c9f268ec20bc Mon Sep 17 00:00:00 2001 From: Sudharsan Selvaraj Date: Sun, 30 Jan 2022 16:53:19 +0530 Subject: [PATCH] User can now define specific device udid's as part of capability object (#323) * Add new capability to define list of device udid's to be included in device pool. * update readme * bump version for release Co-authored-by: saikrishna321 --- README.md | 3 ++- package-lock.json | 5 ++--- package.json | 2 +- src/plugin.ts | 13 +++++++++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a54edfe17..4d24d2b7c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ The plugin will not be active unless turned on when invoking the Appium server: ``` appium server -ka 800 --use-plugins=device-farm,appium-dashboard -pa /wd/hub --plugin-device-farm-platform=android -Arguments options: +Arguments options: * Android - If you want to use only Android devices for parallel execution. * iOS - If you want to use only iOS devices and simulator for parallel execution. @@ -55,6 +55,7 @@ Arguments options: | appium:iPadOnly | Allocate only iPad simulators for execution when to true. Default value is `false`. | | appium:deviceAvailabilityTimeout | When create session requests are more than available connected devices, plugin waits for a certain interval for device availability before it timeout. Default value is `180000` milliseconds. | | appium:deviceRetryInterval | When create session requests are more than available connected devices, plugin polls for device availability in certain intervals. Default value is `10000` milliseconds. | +| appium:udids | Comma separated list of device udid's to execute tests only on specific devices `appium:udids: device1UDID,device2UDID` | ## Example diff --git a/package-lock.json b/package-lock.json index c669872dc..ab76a310b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,11 @@ { "name": "appium-device-farm", - "version": "1.0.0-beta.11", + "version": "1.0.0-beta.12", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "appium-device-farm", - "version": "1.0.0-beta.11", + "version": "1.0.0-beta.12", "license": "ISC", "dependencies": { "@appium/base-plugin": "^1.8.0", diff --git a/package.json b/package.json index 3936ee3b4..3f45844ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "appium-device-farm", - "version": "1.0.0-beta.11", + "version": "1.0.0-beta.12", "description": "An appium 2.0 plugin that manages and create driver session on available devices", "main": "./lib/index.js", "scripts": { diff --git a/src/plugin.ts b/src/plugin.ts index af396db7c..95e36db56 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -35,6 +35,7 @@ const customCapability = { deviceQueryInteval: 'appium:deviceRetryInterval', iphoneOnly: 'appium:iPhoneOnly', ipadOnly: 'appium:iPadOnly', + udids: 'appium:udids', }; let timer: any; @@ -49,12 +50,18 @@ export class DevicePlugin extends BasePlugin { Platform: { isString: true, }, + UDIDS: { + isString: true, + required: true, + }, }; } onUnexpectedShutdown(driver: any, cause: any) { unblockDevice(driver.sessionId); - log.info(`Unblocking device mapped with sessionId ${driver.sessionId} onUnexpectedShutdown from server`); + log.info( + `Unblocking device mapped with sessionId ${driver.sessionId} onUnexpectedShutdown from server` + ); } public static async updateServer(expressApp: any): Promise { @@ -169,7 +176,9 @@ export class DevicePlugin extends BasePlugin { */ static getDeviceFiltersFromCapability(capability: any): IDeviceFilterOptions { const platform: Platform = capability['platformName'].toLowerCase(); - const udids = process.env.UDIDS?.split(','); + const udids = capability[customCapability.udids] + ? capability[customCapability.udids].split(',') + : process.env.UDIDS?.split(','); /* Based on the app file extension, we will decide whether to run the * test on real device or simulator. *