Error while executing appium script in java on ios device


#1

I am using
Xcode- 8.2
Appium-1.6.3
MacOS- 10.12
iOS- 10.2

My code is having following capabilities-

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,“iOS”);
capabilities.setCapability(“udid”,“xxxx”);
capabilities.setCapability(“app”,"/Users/Desktop/Payload/mobilebanking.app") capabilities.setCapability(“app”,"/Usersfo/Desktop/LTMobileBankingAfterUpdate/mobilebanking.app");
capabilities.setCapability(“automationName”,“XCUITest”);
driver = new IOSDriver(new URL(“http://127.0.0.1:4723/wd/hub”),capabilities);

I get the following error for ios WebApp or any Native app -

[Appium] Welcome to Appium v1.6.3
[Appium] Non-default server args:
[Appium] sessionOverride: true
[Appium] fullReset: true
[Appium] Deprecated server args:
[Appium] --full-reset => --default-capabilities ‘{“fullReset”:true}’
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium] fullReset: true
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
Appium server started.
[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“automationName”:“XCUITest”,“app”:"/Users/infotech/Desktop/SafariLauncherAfterUpdate/SafariLauncher.app",“deviceName”:“iOS”,“platformName”:“iOS”,“udid”:“xxxx”}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{“automationName”:“XCUITest”,“app”:"/Users/nfotech/Desktop/SafariLauncherAfterUpdate/SafariLauncher.app",“deviceName”:“iOS”,“platformName”:“iOS”,“udid”:“xxxx”},null,null,null,null]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1490264027778 (15:43:47 GMT+0530 (IST))
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] automationName: ‘XCUITest’
[Appium] app: ‘/Users/infotech/Desktop/SafariLauncherAfterUpdate/SafariLauncher.app’
[Appium] deviceName: ‘iOS’
[Appium] platformName: ‘iOS’
[Appium] udid: ‘xxxx’
[Appium] fullReset: true
[debug] [XCUITest] XCUITestDriver version: 2.23.1
[BaseDriver] Session created with session id: a5d95ed8-ab29-4ef3-bb1f-c0c7a4caba91
[debug] [XCUITest] Xcode version set to ‘8.2.1’ (tools v8.2.0.0.1.1480973914)
[debug] [XCUITest] iOS SDK Version set to ‘10.2’
[debug] [BaseDriver] Event ‘xcodeDetailsRetrieved’ logged at 1490264027904 (15:43:47 GMT+0530 (IST))
[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: ‘xxxx’
at XCUITestDriver.determineDevice$ (…/…/lib/driver.js:577:17)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at run (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:108:47)
at /usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:119:28
at flush (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.microtask.js:19:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[Error: Unknown device or simulator UDID: ‘xxxx’]
[MJSONWP] Encountered internal error running command: Error: Unknown device or simulator UDID: ‘xxxx’
at XCUITestDriver.determineDevice$ (…/…/lib/driver.js:577:17)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at run (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:108:47)
at /usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:119:28
at flush (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.microtask.js:19:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[HTTP] <-- POST /wd/hub/session 500 238 ms - 213
Exception in thread “main” org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unknown device or simulator UDID: ‘xxxx’ (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 603 milliseconds
Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:30’
System info: host: ‘fitechs-mac-mini.local’, ip: ‘192.168.2.1’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.3’, java.version: ‘1.7.0_65’
Driver info: io.appium.java_client.ios.IOSDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:176)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:107)
at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:23)
at IOSWebTest.main(IOSWebTest.java:122)

I have already installed libimobiledevice…

Also when I type java-version in terminal. I get java 1.8.0
But in eclipse logs its showing java version 1.7.0. Can this be the cause of problem. What is the solution?


#2

[XCUITest] Error: Unknown device or simulator UDID: ‘xxxx’
You must check devices connect to your laptop.
If you use mac - in console : ios-deploy -c
It will show list connected real devices.
Copy id device to your code


#3

@Wafe_is_7 Still getting same problem…


#4

ios-deploy -c after this command - what is in console?


#5

@Wafe_is_7
ios-deploy -c
[…] Waiting up to 5 seconds for iOS device to be connected
[…] Found xxxxxxxxxxxxxxxxxx (P101AP, iPad 4, iphoneos, armv7s) a.k.a. ‘infotech’s iPad’ connected through USB.


#6

try to set in capability name of device


#7
  • it is in your capability
    in appium – Users/infotech/Desktop/SafariLauncherAfterUpdate/SafariLauncher.app

You want to launch Safari?
For real device you need app.ipa


#8

brew install libimobiledevice --HEAD – Did you do it?


#9

@Wafe_is_7 Yes I did it.
I have provisioned profile safariLauncher. So should I use .ipa in place of .app


#10

@Wafe_is_7 I have tried installing both MobileBanking app and Safari. For both scripts I am getting same error


#11

For real devices you need file.ipa
For Simulators you need file.app
I don`t launch safari with appium.

Just try to launch without safari!


#12

@Wafe_is_7 But how to launch webapp without safari?? Do you have code for it??


#13

@Wafe_is_7 I am getting same error even after using .ipa.


#14

how do you start appium?


#15

@Wafe_is_7 I am starting appium from java code.

CommandLine command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/usr/local/bin/appium",false);
command.addArgument("–address", false);
command.addArgument(“0.0.0.0”);
command.addArgument("–port", false);
command.addArgument(“4723”);
command.addArgument("-bp", false);
command.addArgument(“4724”);
command.addArgument("–full-reset", true);
command.addArgument("–session-override", true);
//command.addArgument("–no-reset", true);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {executor.execute(command, resultHandler);
Thread.sleep(5000);System.out.println(“Appium server started.”);}

I am using Appium 1.6.3. I am n not having UI version. Is the path of node and appium correct?? Because the path of node that I am using is from older appium version.


#16

I don`t start appium from code!

I start appium from console!

: appium --address (your address) --port(your port) --session-override


#17

@Wafe_is_7 It is working fine when I start server manually. But when I start using Java Code it is giving error.


#18

Hi…I am also facing similar issue. Appium is not able to find the connected device. I am using appium 1.6.4-beta6.

[debug] [XCUITest] Xcode version set to ‘8.2.1’ (tools v8.2.0.0.1.1480973914)
[debug] [XCUITest] iOS SDK Version set to ‘10.2’
[debug] [BaseDriver] Event ‘xcodeDetailsRetrieved’ logged at 1490432945221 (14:39:05 GMT+0530 (IST))
[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: ‘d7e9ea82703b2905bf0f5a969d925dc8692ef56c’

however idevice_id -l does return me the device udid.

I am just not able to find the best possible configuration to get it running.


#19

When you start appium from consol with jaca code, you have error with ‘device ID’ - ?


#20

@Wafe_is_7 When I start appium from Terminal and then execute my java code the application is getting invoked.