AppiumTestDistribution / appium-device-farm

This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
https://devicefarm.org
Other
335 stars 102 forks source link

appium-device-farm replaces my capabilities and sends them to the Appium server. #725

Closed win5923 closed 1 year ago

win5923 commented 1 year ago

Describe the bug

I am performing end-to-end (e2e) testing using Appium. However, when I set the capabilities to a specific device, Appium always automatically captures the first available device, even if I replace deviceName with udid.

adb devices -l
List of devices attached
RKCXXZ0102             device usb:1-2 product:zx70g2_LTE model:ZX70G2 device:zx70g2 transport_id:2
RKCXXZ0140             device usb:1-7 product:zx70g2_LTE model:ZX70G2 device:zx70g2 transport_id:1

Link to Appium logs

GIST

change to udid

{
  platformName: 'Android',
  'appium:automationName': 'uiautomator2',
  'appium:udid': 'RKCXXZ0140',
  'appium:platformVersion': '10',
  'appium:ensureWebviewsHavePages': true,
  'appium:nativeWebScreenshot': true,
  'appium:newCommandTimeout': 3600,
  'appium:connectHardwareKeyboard': true
}
[device-farm] {"platform":"android","platformVersion":"10","name":"","busy":false,"userBlocked":false}
[device-farm] Waiting for free device
[device-farm] 📱 Device found: {"adbRemoteHost":null,"adbPort":5037,"systemPort":45641,"sdk":"10","realDevice":true,"name":"QCOM-BTD","busy":false,"state":"offline","udid":"RKCXXZ0174","platform":"android","deviceType":"real","host":"http://192.168.60.215:4723","totalUtilizationTimeMilliSec":0,"sessionStartTime":0,"offline":false,"userBlocked":false,"meta":{"revision":0,"created":1684834514368,"version":0},"$loki":1,"dashboard_link":"http://192.168.99.58:30002/dashboard?device_udid=RKCXXZ0174&start_time=2023-05-23T09:34:51.311Z","total_session_count":0}
[device-farm] 📱 Blocking device RKCXXZ0174 for new session
[AppiumDriver@e097] Plugin appium-dashboard is now handling cmd 'createSession'
[AppiumDriver@e097] Executing default handling behavior for command 'createSession'
[debug] [AppiumDriver@e097] Event 'newSessionRequested' logged at 1684834549264 (09:35:49 GMT+0000 (Coordinated Universal Time))
[Appium] Attempting to find matching driver for automationName 'uiautomator2' and platformName 'Android'
[Appium] The 'uiautomator2' driver was installed and matched caps.
[Appium] Will require it at /home/androidusr/.appium/node_modules/appium-uiautomator2-driver
[debug] [Appium] Requiring driver at /home/androidusr/.appium/node_modules/appium-uiautomator2-driver
[AppiumDriver@e097] Appium v2.0.0-beta.71 creating new AndroidUiautomator2Driver (v2.25.0) session
[AppiumDriver@e097] Checking BaseDriver versions for Appium and AndroidUiautomator2Driver
[AppiumDriver@e097] Appium's BaseDriver version is 9.3.10
[AppiumDriver@e097] AndroidUiautomator2Driver's BaseDriver version is 9.3.10
[AppiumDriver@e097] Applying relaxed security to 'AndroidUiautomator2Driver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure
[debug] [AndroidUiautomator2Driver@0c08] Creating session with W3C capabilities: {
[debug] [AndroidUiautomator2Driver@0c08]   "alwaysMatch": {
[debug] [AndroidUiautomator2Driver@0c08]     "platformName": "Android",
[debug] [AndroidUiautomator2Driver@0c08]     "appium:automationName": "uiautomator2",
[debug] [AndroidUiautomator2Driver@0c08]     "appium:platformVersion": "10",
[debug] [AndroidUiautomator2Driver@0c08]     "appium:ensureWebviewsHavePages": true,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:nativeWebScreenshot": true,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:newCommandTimeout": 3600,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:connectHardwareKeyboard": true,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:clearDeviceLogsOnStart": true,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:udid": "RKCXXZ0174",
[debug] [AndroidUiautomator2Driver@0c08]     "appium:systemPort": 41883,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:chromeDriverPort": 44669,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:adbRemoteHost": null,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:adbPort": 5037,
[debug] [AndroidUiautomator2Driver@0c08]     "appium:mjpegServerPort": 41707
[debug] [AndroidUiautomator2Driver@0c08]   },
[debug] [AndroidUiautomator2Driver@0c08]   "firstMatch": [
[debug] [AndroidUiautomator2Driver@0c08]     {}
[debug] [AndroidUiautomator2Driver@0c08]   ]
[debug] [AndroidUiautomator2Driver@0c08] }

Expected Behavior

I wish that when I set the udid or device name, Appium would be able to capture the correct device.

Minimal Reproducible Example

I am using https://github.com/appium/appium-docker-android and install device-farm and appium-dashboard with Docker Appium.

below is my capabilities: { platformName: 'Android', 'appium:automationName': 'uiautomator2', 'appium:udid': 'RKCXXZ0174', 'appium:platformVersion': '10', 'appium:ensureWebviewsHavePages': true, 'appium:nativeWebScreenshot': true, 'appium:newCommandTimeout': 3600, 'appium:connectHardwareKeyboard': true }

but Appium-device-farm always automatically captures the first available device.

Environment

  1. Appium version (or git revision) that exhibits the issue: v2.0.0-beta.71
  2. Last Appium version that did not exhibit the issue (if applicable):
  3. Node.js version (unless using Appium.app|exe): 18.16.0
  4. Npm or Yarn package manager: 9.5.1
  5. Mobile platform/version under test: Android 10
  6. Real device or emulator/simulator: Real device
  7. Appium CLI or Appium.app|exe: --relaxed-security --use-plugins=device-farm,appium-dashboard --plugin-device-farm-platform=android
saikrishna321 commented 1 year ago

@win5923 The plugin currently gets all the devices in the order appium returns and picks the free device. If you want to only run on specific devices please check this

https://github.com/AppiumTestDistribution/appium-device-farm#capabilities

appium:udids Comma separated list of device udid's to execute tests only on specific devices appium:udids: device1UDID,device2UDID
win5923 commented 1 year ago

Thank you very much.