Iphone 5 Appium and jUnit - App did not have elements - ios

I have a problem with my automated tests on iPhone 5. I could previously start test on iPad with iOS 6.1 but now I would like to do it on iPhone 5 iOS 8.1
In eclipse I got message A new session could not be created.
Log from appium:
error: Failed to start an Appium session, err was: Error: App did not have elements
info: [debug] Error: App did not have elements
at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ ios.js:459:30
at Object.cb [as callback] (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios /ios-controller.js:247:7)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:801:43)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:32:16
at exports.respond (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/common.js:28:9)
at null.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios.js:1449:18)
at getResultAndSendNext (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/lib/command-proxy.js:146:20)
at Socket.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/lib/command-proxy.js:88:7)
at Socket.emit (events.js:117:20)
at _stream_readable.js:944:16
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: App did not have elements)","origValue":"App did not have elements"},"sessionId":null}
info: <-- POST /wd/hub/session 500 29025.843 ms - 172
capabilities:
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.1");
capabilities.setCapability("deviceName", "iPhone 5 iOS 8.1");
capabilities.setCapability("udid","104ce995950282f9dfaf371bf05ee6b00e7c0027);
Can anybody help me?

Beginning iOS 8, excessive amount of NSLog outputs can create deadlock in the internal communication of UIAutomation and Appium server. (read this article for more info Appium's Github page)
This causes such undesired outcomes.
A preventive workaround is described HERE: which solved the issue on my case. I hope it will help.

Related

issue to run ios app from appium

I'm trying to run an iOS app with appium i've searched several examples on internet and this is with what i've come out :
public class NotAScenario {
IOSDriver driver;
#BeforeTest
public void start() throws InterruptedException, MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformName", "iOS");
caps.setCapability("platformVersion", "9.3");
caps.setCapability("deviceName", "mydevicename");
caps.setCapability("app", "myipafile.ipa");
driver = new IOSDriver(new URL("http://127.0.0.0:4723/wd/hub"), caps);
sleep(5000);
}
#AfterTest
public void end() throws InterruptedException {
sleep(5000);
driver.quit();
}
#Test
public void test() throws InterruptedException {
System.out.println("test");
sleep(5000);
}
}
I tried with an real device iphone 5S, I tried with a simulator same result the app just open/close in 0.5 sec in a loop then it crashes and I get this error
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[debug] [Instruments] Attempting to launch instruments, this is try #1
[Instruments] Launching instruments
[debug] [Instruments] Attempting to run app on real device with UDID 'myudid'
[debug] [Instruments] Found Insruments-Without-Delay: /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-instruments/thirdparty/iwd7
[debug] [Instruments] Spawning instruments with command: '/Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /var/folders/sw/w9bk_9_96s1bwz15mzxk3qpd7lj5f9/T/appium-instruments/instrumentscli0.trace -w myudid my.app.package -e UIASCRIPT "/Users/mobileautomation/Library/Application Support/appium/bootstrap/bootstrap-bbff984e2d53a4ae.js" -e UIARESULTSPATH /var/folders/sw/w9bk_9_96s1bwz15mzxk3qpd7lj5f9/T/appium-instruments'
[debug] [Instruments] And extra without-delay env: {}
[debug] [Instruments] And launch timeouts (in ms): {"global":90000}
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[HTTP] <-- GET /wd/hub/status - - ms - -
[HTTP] <-- GET /wd/hub/status - - ms - -
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[debug] [Instruments] [INST STDERR] Instruments Trace Error : Target failed to run: Permission to debug my.app.package was denied. The app must be signed with a development identity (e.g. iOS Developer).
[debug] [Instruments] Instruments exited with code 253
[Instruments] Error launching instruments: Instruments crashed on startup
I've tried to run it from my code, I tried to run it directly from appium and I even tried to run it from Instruments/Automation but I keep on having the same result the :
[INST STDERR] Instruments Trace Error : Target failed to run: Permission to debug my.app.package was denied. The app must be signed with a development identity (e.g. iOS Developer).
I've seen in here that it can be related to the fact that the build is in "Release" and not in "Debug" so I asked the dev team to give me a debug build but I still have the same result.
Could it be that they didn't build it the right way ?
Am I missing something ? Do they need the device name / udid in an allowed file or something ?
EDIT :
I did receive a new build of the dev it was indeed an issue with the provisionning profile that was not in dev & the build settings not in debug
Please use debug build of the app , this problem is due to not using debug build ,you need debug build on iOS in order to automate and make sure ui automation is enabled in developer options
Go to below folder
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform"
I found a folder named (11.2) & My real device version was (11.2.5)
Just Renamed the folder with version name (11.2) -> (11.2.5).
Started working again from me.

iPhone automation using selenium webdriver,java,appium and webkit proxy: Not able to execute more than 1 testcase

I am working on iPhone automation using selenium webdriver, appium & ios webkit debug proxy.
Configurations:
OS X Version 10.11.2
Appium 1.3.5
Xcode: 7.2
Device: iPhone 6[9.2]
I have installed safariLauncher app in iPhone using Xcode.
Steps:
I launched appium through terminal.
Cmd: Appium &
Then launched ios-webkit-debug-proxy.
Cmd: ./bin/ios-webkit-debug-proxy-launcher.js -c [device udid]:27753 -d
I launch appium & webkit server every time before starting any test case execution.
Only the first test case works fine and 2nd test case onward run into below error in appium log:
code error: Failed to start an Appium session, err was: Error: Instruments crashed on startup
info: [debug] Error: Instruments crashed on startup
at Instruments.onInstrumentsExit (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:389:31)
at null.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:308:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null}
info: <-- POST /wd/hub/session 500 153251.340 ms - 182
Please suggest any solution.

Appium [iOS] Instruments crashed on startup

When Appium tries to run application, the screen flashes with app splash screen, as if Appium tries to launch app multiple times. This behaviour happens both on simulator and real device.
I set enable on my iOS devices UI Automation, but when I try start inspector I have this problem:
info: [debug] [INST STDERR] 2015-11-05 15:11:05.082 instruments[1495:39489] WebKit Threading Violation - initial use of WebKit from a secondary thread.
info: [debug] [INST STDERR] 2015-11-05 15:11:06.049 instruments[1495:39460] Attempting to change event horizon while disengage
error: Failed to start an Appium session, err was: Error: Instruments crashed on startup
info: [debug] [INST STDERR] 2015-11-05 15:11:06.049 instruments[1495:39462] Attempting to change event horizon while disengage
Instruments Trace Error : Target failed to run: Permission to debug com.myapp.iphone was denied. The app must be signed with a development identity (e.g. iOS Developer).
info: [IOS_SYSLOG_ROW ] Nov 5 15:11:04 tests-iPod com.apple.xpc.launchd[1] (UIKitApplication:com.myapp.iphone[0xe163][607]) <Notice>: Service exited due to signal: Killed: 9
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] We exceeded the number of retries allowed for instruments to successfully start; failing launch
info: [debug] Stopping iOS log capture
info: [debug] Reset not set, not ending sim or cleaning up app state
info: [debug] Cleaning up appium session
info: [debug] Error: Instruments crashed on startup
at [object Object].Instruments.onInstrumentsExit (/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-instruments/lib/instruments.js:440:31)
at [object Object].<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-instruments/lib/instruments.js:353:12)
at ChildProcess.emit (events.js:110:17)
at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null
info: <-- POST /wd/hub/session 500 33841.937 ms - 182}
Application is in form of .ipa
Target failed to run: Permission to debug com.myapp.iphone was denied.
The app must be signed with a development identity (e.g. iOS Developer).
You application should be signed with developers key. Click here for documentation
If you are using iOS Simulator, do the following...
In Appium, go to Developer Settings, Check Custome Server Flags and write --native-instruments-lib in the text box.
Now start Appium Server.
Hope this helps!
BlockquoteTarget failed to run: Permission to debug com.myapp.iphone was denied.
The app must be signed with a development identity (e.g. iOS Developer).
Blockquote
You should give your developer identity while creating the .ipa...
If you are creating ipa file through terminal, you can follow the given link [blog]: Xcode "Build and Archive" from command line
I also struggled with this problem and found that you need to enable UI automation in developer option in you iDevice
How to enable UI Automation
1. switch off the iDevice,
2. then connect it to the Mac running Xcode
3. before switching it back on to have Developer options appear.
4. tap on developer option and Enable UI automation
In my case, the following command made my life hell:
rm -rf $HOME/Library/Developer/Xcode/iOS\ DeviceSupport/*
So don't add it to the build step.
To fix the issue:
Restart device > run Xcode > connect device > build & run the app > stop & quit Xcode
Now verify launching app without crashing the instruments.

Appium-Help required: Simulator is not launching application from Appium.app

Having problems in running Appium app for automation mobile app testing
Following tool versions I'm using
Appium version: 1.2.1
Xcode: 5.1.1
Following are the steps which I’m doing,
Download Appium.dmg
Run dmg file and then launched appium.app file
Build application for 7.1 simulator from Xcode
On appium.app, enabled ‘App Path’ option and provided .app file path “/Users/umairrashid/Library/Application Support/iPhone Simulator/7.1/Applications/878133B5-7078-4E92-B3A2-607A3A3C2AC3/Recipes.app”
In ‘General Settings’,
Server Address: 127.0.0.1, Port: 4723
Check for Updates: Enabled
New Command Timeout: 7200s
When I click ‘Launch’ button then everything seems to be okay.
When I click ‘Inspector’ button then following errors displayed,
Could Not Launch Appium Inspector
Could not start a new session
Be sure the Appium server is running with an application opened by using the "App Path" parameter in Appium.app (along with package and activity for Android) or by connecting with selenium client and supplying this in the desired capabilities object.
In Appium Console, I got following error,
2014-08-21T17:57:57.789Z - info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"iOS","platformVersion":"7.1","newCommandTimeout":"999999","automationName":"Appium"}}
2014-08-21T17:57:57.792Z - info: <-- POST /wd/hub/session 500 3.235 ms - 286
2014-08-21T17:57:57.772Z - debug: Request received with params: {}
2014-08-21T17:57:57.772Z - debug: Responding to client with success: {"status":0,"value":{"build":{"version":"1.2.0","revision":"e53f49c706a25242e66d36685c268b599cc18da5"}}}
2014-08-21T17:57:57.775Z - debug: Appium request initiated at /wd/hub/sessions
2014-08-21T17:57:57.775Z - debug: Request received with params: {}
2014-08-21T17:57:57.775Z - debug: Responding to client with success: {"status":0,"value":[]}
2014-08-21T17:57:57.789Z - debug: Appium request initiated at /wd/hub/session
2014-08-21T17:57:57.789Z - debug: Request received with params: {"desiredCapabilities":{"platformName":"iOS","platformVersion":"7.1","newCommandTimeout":"999999","automationName":"Appium"}}
2014-08-21T17:57:57.790Z - error: The following desired capabilities are required, but were not provided: deviceName
2014-08-21T17:57:57.790Z - debug: Got configuration error, not starting session
2014-08-21T17:57:57.791Z - debug: Cleaning up appium session
2014-08-21T17:57:57.791Z - error: Failed to start an Appium session, err was: Error: The following desired capabilities are required, but were not provided: deviceName
2014-08-21T17:57:57.791Z - debug: Error: The following desired capabilities are required, but were not provided: deviceName
at Capabilities.checkValidity (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/lib/server/capabilities.js:120:13)
at Appium.configure (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:256:35)
at Appium.start (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:100:10)
at Object.exports.createSession [as handle] (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/lib/server/controller.js:159:16)
at next_layer (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/route.js:103:13)
at Route.dispatch (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/route.js:107:5)
at /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:213:24
at Function.proto.process_params (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:286:12)
at next (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:207:19)
at next (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:182:38)
2014-08-21T17:57:57.791Z - debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: deviceName)","origValue":"The following desired capabilities are required, but were not provided: deviceName"},"sessionId":null}
2014-08-21T17:58:08.130Z - info: --> GET /wd/hub/status {}
—————————————————
When Launching with ‘Prelaunch Application’:Enabled, got following errors
2014-08-21T18:00:55.417Z - debug: Attempting to retry launching instruments, this is retry #3
2014-08-21T18:00:55.418Z - debug: Killall iPhoneSimulator
2014-08-21T18:01:00.420Z - info: Launching instruments
2014-08-21T18:01:00.421Z - debug: Attempting to run app on iPhone Retina (4-inch) - Simulator - iOS 7.1
2014-08-21T18:01:00.422Z - debug: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w iPhone Retina (4-inch) - Simulator - iOS 7.1 /Users/umairrashid/Library/Application Support/iPhone Simulator/7.1/Applications/878133B5-7078-4E92-B3A2-607A3A3C2AC3/Recipes.app -e UIASCRIPT /Users/umairrashid/Library/Application Support/appium/bootstrap/bootstrap-7a459bb511e03f3b.js -e UIARESULTSPATH /tmp/appium-instruments
2014-08-21T18:01:00.422Z - debug: And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd/InstrumentsShim.dylib","LIB_PATH":"/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd"}
2014-08-21T18:01:00.422Z - debug: And launch timeouts (in ms): {"global":90000}
2014-08-21T18:01:01.415Z - debug: [INST STDERR] Instruments Usage Error : Could not remove existing output document 'file:///Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/instrumentscli0.trace': Error Domain=NSCocoaErrorDomain Code=642 "You can’t save the file “instrumentscli0.trace” because the volume “Appium” is read only." UserInfo=0x7fac5e2d6100 {NSFilePath=/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/instrumentscli0.trace, NSUnderlyingError=0x7fac5d92d760 "The operation couldn’t be completed. Read-only file system"}.
2014-08-21T18:01:01.483Z - debug: [INSTSERVER] Instruments exited with code 254
2014-08-21T18:01:01.483Z - debug: Killall instruments
2014-08-21T18:01:01.486Z - debug: Instruments crashed on startup
Here I'm expecting that when I click Inspect button from Appium then Simulator is launched and I can see XPaths etc in that view.
Are you sure you have the icon of apple selected(Sometimes we do silly misclicks)
If you have have "force device" checked please uncheck it.
If you still have problems it would be better for you to take screenshots of your appium gui and post it here so I can help in a more through way
Are you sure that you have installed Appium by dragging Appium.app to your apps folder?
The below error message suggests that you are just launching it from the DMG file.
Instruments Usage Error : Could not remove existing output document 'file:///Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/instrumentscli0.trace'

how to run appium tests in selendroid mode (API<17)>

I want to run automation test on real devices, earlier i did this on emulators (API>17) but the same test i was trying to run on Appium in selendroid mode it failed.
Below is the capabilities i configured for appium to run in selendroid mode.
Appium Version : 1.0
Selendroid Version: 0.10
I run appium on port no : 6001 and bootstrap port : 4001, And selendroid server run on default port : 8080
private static String url = "http://localhost:"
+ System.getProperty("appium_port") + "/wd/hub";
private AppiumDriver driver;
private static DesiredCapabilities capabilities;
capabilities = new DesiredCapabilities();
File app = new File("en-android.apk");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Selendroid");
capabilities.setCapability(CapabilityType.PLATFORM, "ANDROID");
capabilities.setCapability("device", "Selendroid");
capabilities.setCapability("platformVersion", "4.1.2");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("app-activity",
"testapp.android.gui.WelcomeActivity");
capabilities.setCapability("app-package",
"testapp.android");
driver = new AppiumDriver(new URL(url), capabilities);
Below is Applium server logs.
Appium Log:
error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.
info: Stopping logcat capture
debug: Logcat terminated with code null, signal SIGTERM
info: Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: Cleaning up android objects
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.
info: Error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.
at /home/priyankpshah/.linuxbrew/lib/node_modules/appium/lib/devices/android/android.js:263:17
at /home/priyankpshah/.linuxbrew/lib/node_modules/appium/lib/devices/android/adb.js:630:7
at /home/priyankpshah/.linuxbrew/lib/node_modules/appium/lib/devices/android/adb.js:154:5
at ChildProcess.exithandler (child_process.js:635:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Socket.<anonymous> (child_process.js:956:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.)","origValue":"Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device."},"sessionId":null}
POST /wd/hub/session 500 7269ms - 400b
Tests run: 4, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 8.198 sec <<< FAILURE! - in TestSuite
setUp(com.ishisystems.enigma.EnigmaLaunchTest) Time elapsed: 8.084 sec <<< FAILURE!
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 7.41 seconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'ishiahm-lt113', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.7.0_55'
Driver info: io.appium.java_client.AppiumDriver
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:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:76)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:41)
at TestUtility.automationInit(TestUtility.java:41)
at LaunchTest.setUp(LaunchTest.java:33)
Please let me know is there any specific changes need to be made to run appium tests on selendroid mode on real devices.
Thanks,
Priyank P Shah
If you are using Appium 1.0 use capability 'automationName' instead of device.
E.G.
capabilities.setCapability("automationName", "Selendroid");
instead of
capabilities.setCapability("device", "Selendroid");
For appium versions less than 1.0 beta , you can continue with 'device' capability.

Resources