Forum Discussion

Keith_S's avatar
Keith_S
Occasional Contributor
6 months ago

How to retrieve device ID in run-tests script

Hello. I have tests working on BitBar for both iOS and Android with Appium and AltTester by manually uploading the run-tests script and app build. When doing this manually, I know the device that the test will run on, so I know what capabilities file I need to use ahead of time when initializing AppiumDriver.

However, I'm integrating our tests now to run via a Jenkins pipeline. The device(s) to be run on is chosen from the Jenkins pipeline and can change from run to run. This means that my tests need to dynamically discover which device the test is being run on, so that it can then load the correct capabilities file.

Is there a way to find out which device the test will be run on from within the run-tests script prior to launching the test with maven? I realize that I could probably use "xcrun xctrace list devices" or "adb devices", but that's a little bit messy. I was hoping there is a better way to do this that BitBar supports.

Alternatively, is it possible to retrieve a set of capabilities for the device that the test will be run on, from within the run-tests script?

Thank you

  • To follow up on this, it turns out that you need no device-specific information in your capabilities file in order to connect AltDriver to the devices (for iOS or Android). I'm not sure why this works on BitBar, but not when I run tests locally on my machine. But simply removing the device ID name, OS version (anything device-specific) works for me when running on BitBar.

  • Keith_S's avatar
    Keith_S
    Occasional Contributor

    To follow up on this, it turns out that you need no device-specific information in your capabilities file in order to connect AltDriver to the devices (for iOS or Android). I'm not sure why this works on BitBar, but not when I run tests locally on my machine. But simply removing the device ID name, OS version (anything device-specific) works for me when running on BitBar.