Appium + Jenkins + Real device IOS

Hello guys! I need your help)

I need run appium test on ios real device in jenkins. I have jenkins on local machine.

My settings test:

capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “IOS”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “11.2.1”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “Iphone”);
capabilities.setCapability(MobileCapabilityType.UDID, 74859bb7c435945dafd8691be871ef96905030322);
capabilities.setCapability(MobileCapabilityType.APP, “/Users/TEST/Library/Developer/Xcode/DerivedData/WebDriverAgent-cvqckynzuuktkogfpkkkgyompmoj/Build/Products/Debug-iphoneos/IntegrationApp.app”);
Test successfully run if i run it in Intellij Idea + maven (mvn test) BUT when i run test in jenkins i have error:

/START APPIUM SERVER/…
[Appium] Creating new XCUITestDriver (v2.68.0) session
[Appium] Capabilities:
[Appium] app: /Users/TEST/Library/Developer/Xcode/DerivedData/WebDriverAgent-cvqckynzuuktkogfpkkkgyompmoj/Build/Products/Debug-iphoneos/IntegrationApp.app
[Appium] platformVersion: 11.2.1
[Appium] platformName: IOS
[Appium] udid: 74859bb7c435945dafd8691be871ef96905030322
[Appium] deviceName: Iphone
[BaseDriver] Expected W3C “capabilities” to be a JSON Object but was provided with: []
[BaseDriver] Falling back to MJSONWP desired capabilities
[BaseDriver] Session created with session id: b1797f6a-47ec-4dfc-8099-abc01aeaf878
[XCUITest] The ‘idevice_id’ program is not installed. If you are running a real device test it is necessary. Install with ‘brew install libimobiledevice --HEAD’
[XCUITest] Error: Unknown device or simulator UDID: ‘74859bb7c435945dafd8691be871ef96905030322’
BUT libimobiledevice is already installed

Help me, please!

Did you ever figure out how to get around this?

I’m having the same issue, and I believe it’s because it’s running as Jenkins user instead of current user, and it’e unable to find connected device associated with Jenkins user.

I"m guessing I have to add or modify a plugin to to change the path where it looks for the device.

Any help would be appreciated.

No, it happens because PATH is not set properly: https://github.com/appium/java-client/blob/master/docs/environment.md

Thanks for the reply. When I run from Maven on Eclipse everything work correctly.

Wouldn’t that use the same PATH variables?

From Jenkins Console

[debug] [XCUITest] Current user: ‘jenkins’
[XCUITest] The ‘idevice_id’ program is not installed. If you are running a real device test it is necessary. Install with ‘brew install libimobiledevice --HEAD’
[debug] [XCUITest] Available devices:
[XCUITest] Error: Unknown device or simulator UDID: ‘c8be317ecec81cd9b8d06b47bcb575a7f46ced57’
[XCUITest] at /Users/mpsadmin/.nvm/versions/node/v11.0.0/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:707:17

@dduphorn

  1. first - say how you run your test job with jenkins. does the job runs on same machine where jenkins runs or on slave
  2. to check PATH issue add into jenkins job command “echo $PATH” and check - does it show ALLLL paths as you do it manually on machine where you have NO problem to run your test.
  1. I’m executing the job from my user on the same machine where jenkins user exists.
  2. Where is the Jenkins Job Command? Is it the Pre Steps section Execute shell?

execute shell - is fine to check. on any step.

//User
/Users/mpsadmin/.nvm/versions/node/v11.0.0/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin:/Users/mpsadmin/Library/Android/sdk/tools:/Users/mpsadmin/Library/Android/sdk/platform-tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

//Jenkins
/Users/Shared/Jenkins/.nvm/versions/node/v11.0.0/bin:/usr/local/Cellar/maven/3.5.3/libexec/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin:/Users/Shared/Jenkins/.nvm/versions/node/v11.0.0/bin:/usr/bin:/bin:/usr/sbin:/sbin
/Users/Shared/Jenkins/.nvm/versions/node/v11.0.0/bin:/usr/local/Cellar/maven/3.5.3/libexec/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin:/Users/Shared/Jenkins/.nvm/versions/node/v11.0.0/bin:/usr/bin:/bin:/usr/sbin:/sbin

Now how do I get them in sync?

you have some options:

  1. add absent path to your node (if it same = master then to master)
  2. add path to job itself (Add Build Step -> Inject Environment variable)
  3. finally add path in same job with SAME execute shell script as you starting your job. just add one line before
  4. global config of jenkins

choose any you like

I’ll give it a shot. Thanks for your assistance.

// I set it to use the path that maven uses.
export PATH=/Users/mpsadmin/.nvm/versions/node/v11.0.0/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin:/Users/mpsadmin/Library/Android/sdk/tools:/Users/mpsadmin/Library/Android/sdk/platform-tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
echo $PATH

And I still go the error:
[debug] [XCUITest] Current user: ‘jenkins’
[XCUITest] The ‘idevice_id’ program is not installed. If you are running a real device test it is necessary. Install with ‘brew install libimobiledevice --HEAD’
[debug] [XCUITest] Available devices:

Thoughts?

your jenkins is running under another user? if it is check that libimobiledevice installed under that user.

I did logout as current user and login as jenkins user, and I verified libimobiledevice was installed, and I ran idevice_id -l, and saw my device existed.

I’m not sure why it’s still trying to execute the idevice program as the jenkins user instead of the current user. I’m trying to locate where that path is being set. It would be nice if you could do it by port instead of user.

try another approach. identify failed appium server commands and execute them in shell with job.

BTW how you start your tests? maven?

When I run the test from Eclipse = Pass
When I run the test from Eclipse using Maven = Pass
When I run the test from Jenkins = Failed.

Not sure what the Falling back to MJSONWP desired capabillities means, but I’m reasearching.

[BaseDriver] Falling back to MJSONWP desired capabilities
[BaseDriver] Session created with session id: 622a4c32-8183-4155-9a41-8a9723da9b96
[debug] [XCUITest] Current user: ‘jenkins’
[XCUITest] The ‘idevice_id’ program is not installed. If you are running a real device test it is necessary.

How about run test in terminal with maven command?

It ran successfully through the maven command from terminal as well.

I decided to update everything to latest( Selenium, Appium) hoping that would fix the issue, but I fucked something up.

I’m getting the below error now.

From Eclipse & Maven:
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/internal/ApacheHttpClient$Factory
at AutomationCode.TestCases.A1_ValidateInvalidCredentialMessage(TestCases.java:266)

I did notice that when I ran appium-doctor a warning came up that the ios command line tools were not installed. I wonder if that caused my issues with attaching to the iOS device.

java.lang.NoClassDefFoundError - is problem in your code. not connected to Appium or Selenium.

I updated my dependency for java-client from 4.2.0 to 6.1.0,

Which informed me that
runAppInBackground(1); changed to runAppInBackground(Duration.ofSeconds(-1));

and

.swipe and .tap no longer work. <-looking for a solution to this now.