Skip to content

Commit

Permalink
User can now define specific device udid's as part of capability obje…
Browse files Browse the repository at this point in the history
…ct (#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 <saikrishna321@yahoo.com>
  • Loading branch information
sudharsan-selvaraj and saikrishna321 authored Jan 30, 2022
1 parent 2bc15cb commit 3ea931a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
13 changes: 11 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const customCapability = {
deviceQueryInteval: 'appium:deviceRetryInterval',
iphoneOnly: 'appium:iPhoneOnly',
ipadOnly: 'appium:iPadOnly',
udids: 'appium:udids',
};

let timer: any;
Expand All @@ -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<void> {
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 3ea931a

Please sign in to comment.