Skip to content

Commit c6735df

Browse files
committed
fix simulator run parallel with android
1 parent 84b1c3a commit c6735df

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "appium-device-plugin",
3-
"version": "1.0.0-beta.2",
3+
"version": "1.0.0-beta.3",
44
"description": "An appium 2.0 plugin that manages and create driver session on available devices",
55
"main": "./lib/index.js",
66
"scripts": {

src/CapabilityManager.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import getPort from 'get-port';
2+
3+
export async function androidCapabilities(caps, freeDevice) {
4+
caps.firstMatch[0]['appium:udid'] = freeDevice.udid;
5+
caps.firstMatch[0]['appium:deviceName'] = freeDevice.udid;
6+
caps.firstMatch[0]['appium:systemPort'] = await getPort();
7+
}
8+
9+
export async function iOSCapabilities(caps, freeDevice) {
10+
caps.firstMatch[0]['appium:udid'] = freeDevice.udid;
11+
caps.firstMatch[0]['appium:deviceName'] = freeDevice.udid;
12+
caps.firstMatch[0]['appium:wdaLocalPort'] = await getPort();
13+
}

src/Devices.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export default class Devices {
4848
getFreeDevice(platform) {
4949
log.info(`Finding Free Device for Platform ${platform}`);
5050
return actualDevices.find(
51-
(device) => device.busy === false && device.platform === platform
51+
(device) =>
52+
device.busy === false && device.platform.toLowerCase() === platform
5253
);
5354
}
5455

src/plugin.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import BasePlugin from '@appium/base-plugin';
22
import AndroidDeviceManager from './AndroidDeviceManager';
3-
import getPort from 'get-port';
3+
import { androidCapabilities, iOSCapabilities } from './CapabilityManager';
44
import log from './logger';
55
import Devices from './Devices';
66
import SimulatorManager from './SimulatorManager';
@@ -32,15 +32,11 @@ export default class DevicePlugin extends BasePlugin {
3232
await fetchDevices();
3333
freeDevice = devices.getFreeDevice(caps.firstMatch[0]['platformName']);
3434
if (freeDevice && caps.firstMatch[0]['platformName'] === 'android') {
35-
caps.firstMatch[0]['appium:udid'] = freeDevice.udid;
36-
caps.firstMatch[0]['appium:deviceName'] = freeDevice.udid;
37-
caps.firstMatch[0]['appium:systemPort'] = await getPort();
35+
await androidCapabilities(caps, freeDevice);
3836
devices.blockDevice(freeDevice);
3937
log.info(`Device UDID ${freeDevice.udid} is blocked for execution.`);
40-
} else if (freeDevice && caps.firstMatch[0]['platformName'] === 'iOS') {
41-
caps.firstMatch[0]['appium:udid'] = freeDevice.udid;
42-
caps.firstMatch[0]['appium:deviceName'] = freeDevice.udid;
43-
caps.firstMatch[0]['appium:wdaLocalPort'] = await getPort();
38+
} else if (freeDevice && caps.firstMatch[0]['platformName'] === 'ios') {
39+
await iOSCapabilities(caps, freeDevice);
4440
devices.blockDevice(freeDevice);
4541
log.info(`Device UDID ${freeDevice.udid} is blocked for execution.`);
4642
} else {

0 commit comments

Comments
 (0)