TagAlong: Appium Setup

TagAlong: Appium Setup

NOTE: This is VERY casual writing. Basically; I'm jotting thoughts/steps down kinda haphazardly as I'm going through things. I'm not gonna clean this one up. If I feel like basing a heavy article on it; I will; but here - Pffft; deal with my madness!

The Code

If you're here; you probably want a sample. My sample is SUPER basic - Which can be SUPER nice.
Go to my github for the AppiumJavaExample and you'll find the wonderful simplicity there.


I'm asked to help with getting UI automation going at work. Co-worker who abandoned us has some initial steps to get things going... I need to experience that pain myself.
Time to real time write what I'm doing!!! Ish.
I'm on a Mac; so I may use Mac specific terms and do things you can't do on windows... *looks over at windows machine*... I miss you too Windows-Box

The latest version of Appium 1.6.3 supports XCode 8+; which is required for Swift 3 features (if I remember my details correctly... huh, a blog post without exhaustive research... neat).

I can't find a download for the latest Appium... :\

Apparently I need to install Node to install Appium.

My Set Up:

  • Mac Mini (or work MacBook, one w/o the touch bar)
  • XCode 8.2
  • Swift 3

Later I'll get Team City on here and figure out that integration...

That's all the details I've got... Not sure what I'm doing, really. I like to wing these things. Let's go through my setting up steps...

  • Get Node from Downloads
  • Install Node (I'm installing v6.9.4)
  • Install Appium
  • $ npm install -g appium
  • Install Appium Doctor (guide suggests it)
  • $ npm install -g appium-doctor
  • Download the Appium App
    I verified via $ appium -v that 1.6.3 is installed; to play happy with XCode 8 and Swift 3.

[Note: To skip my extra research; scoll down to the TIME FOR CLI! section]

Now I'm running the Appium.app I downloaded earlier. ... which... Yea... not a lot at the moment.
I'll run the Appium-Doctor to see if I need anything else... apparently I need Appium-Doctor-Doctor.

Quinns-Mac-mini:~ quinngil$ '/Applications/Appium.app/Contents/Resources/node/bin/node' '/Applications/Appium.app/Contents/Resources/node_modules/appium-doctor/appium-doctor.js'
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor  ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer
[Error: Could not detect Mac OS X Version from sw_vers output: '10.12.2
']

Apparently appium-doctor can't detect version OSX 10.12. There's a StackOverflow with the solution, it worked for me.

Once I made the changes there, appium-doctor ran fine and only complained about android and java. Not trying those ATM, so... I'm not gonna fix!

But first I need a thing to test against... I have something from work - Time to... pull it down... get carthage stuff... build... sigh - OK; gimmie a bit; I'll be back.


OK, I've got my project from work (sorry, no source code to show) compiling, and I'm trying to use XCode's UI Test Recorder to record a simple little UI test.
I should say "trying" to record a test... Not sure how the Test Recorder works...

I'm getting some "Time mismatch error" when I click on a field. It was the first field I kept clicking on; so I clicked on another - and it started writing code for me!!!

I now have a UI test doing something. Time to Appiumize (is that a phrase? If not, can I copyright it for all the moniez?)

Launching Appium

I clicked Launch.
Nothing happened.

OK, maybe time to dive into the settings... OH - The apple button is a configuration button; neat. If I'd paid attention at the Appium handoff meeting; I'd know that.


I need to specify the app to test... I don't know where the iOS app is built... TO THE INTERWEBS!!!
An early link is here. Which was a lucky early fined, worked great.
Mostly a note for myself here on how to build:

xcodebuild -showsdks
xcodebuild -arch i386 -sdk iphonesimulator10.2

I selected the app via those instruction; and have re-clicked LAUNCH!
waits enthusiastically
... Oh... Well... maybe an XCUI test isn't gonna work in appium... ya know... heh... whoops.


Now to find how to write a test! TO THE TUBES!
... this is taking a while...
I think I found a resource. It took a bit to really get a good example.
Fortunately the example is from Appium's Sample Code git hub. I'm on a Mac and more familiar with java than the rest; so gonna run with that (which is why the link goes to java/junit). I'd prefer to run with Ruby; but I want to limit my focus and not get distracted getting that set up. Though, I totally have access to RubyMine.
Short version of the directions

  • Create Maven Project
  • Add io.appium dependency
  • Write Tests!!!

It's the 3rd step that's a giant WTF... I filtered through a lot of things. I think SauceLabs put a bounty out on examples using them... almost all samples I found did. hehe

Got the code to mostly compile; a complaint about Java version shakes fist JAAAVVAAAAA!!!!!
There's a pom modificaiton that I found on StackOverflow which resolved that part.


I now have the test running. Not successfully; but it runs.
A lovely error during the test

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'Quinns-Mac-mini.local', ip: '192.168.1.15', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_111'
Driver info: driver.version: IOSDriver

Errr... It still fails; but I thought it wasn't even hitting the server; The Appium app clearly shows it's getting the request... so... huh...

I'm currently staring at the logging in Appium and trying to deduce what could be happening.
I'm apparently sending an incorrect capability

[BaseDriver] The following capabilities were provided, but are not recognized by appium: appium-version.

So I take that out of the code

//capabilities.setCapability("appium-version", "1.5.3");

Running it again still fails, new issue in the logs (PROGRESS!)

[iOS] Could not determine iOS SDK version

This looks really familiar... I think ... The earlier link about finding the app had instructions on building which used SDK this one.
Time to run

$ xcodebuild -showsdks

From this I get a list, I built for iphonesimulator10.2 so I'll try

capabilities.setCapability("sdk", "iphonesimulator10.2");

... Nope.

[debug] [iOS] Cleaned up instruments socket /var/folders/wk/793ymn5j6653khflzbzpwbp40000gn/T/instruments_sock
[debug] [iOS] Setting Xcode version
[debug] [iOS] Xcode version set to 8.2
[debug] [iOS] Setting iOS SDK Version

[iOS] Could not determine iOS SDK version

A following line in the appium log was

[MJSONWP] Encountered internal error running command: Error: Command 'xcrun --sdk iphonesimulator --show-sdk-version' timed out after 3000ms
    at Timeout._onTimeout (lib/teen_process.js:78:19)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)

So I ran that command... took a few to run. I ran it again; almost instant... soo... hmmmm...
I run the test again; Same issue; but it's pure lies that it's timing out after 3seconds. The test fails after less than 2 seconds.

The error was misleading. There's a retry issue. In the iOS settings, under Advanced there's a Backend Retries option. I set it to 5 and it passed the previous issue. The solution was posted on an open appium (issue)[https://github.com/appium/appium/issues/6743]

Now from the log I see

[MJSONWP] Encountered internal error running command: Error: Xcode version [object Object] is not yet supported

Which... Yea... The App is version 1.5.3 and to work with xcode 8 requires 1.6. Since I have appium 1.6.3 installed, it's just no GUI...

Time to CLI this!

Turning to the CLI means that the GUI is out of the picture... duh. Which means all the config file editing; not needed.
I run appium --backend-retries 5 (from the same issue link above).
I can run the test and see some fun new issues

[iOS] SessionNotCreatedError: A new session could not be created. Details: Appium's IosDriver does not support xcode version 8.2. Apple has deprecated UIAutomation. Use the "XCUITest" automationName capability instead.

...researching...

The answer was actually right in the error message; You just have to know enough to know what to do ... already...
The key is Use the "XCUITest" automationName capability instead.
automationName is a capability. Let's se what new issues we can find.
Running the test with that correction...

HOLY SH*T!

Simulator popped up.
It's installing the app!!! Installing app '/Users/quinngil/Documents/workspace/github/myApp/build/AppStore Release-iphonesimulator/TheApp.app

The simulator is taking epically long to start; I kinda expect it to time out. But hey! Got it actually running the simulator.
Didn't time out; just a forever.
It's doing... ... studies logging Looks like it's installing the dependencies it needs on the simulator...

The resource that made me realize it was a capability argument is an Appium documentation page.
This will be useful for configuring a command line invocation to run appium. Tests can still do the configuration, but why worry about it there if it can be done via command line?


The experience so far tells me it'd be good to have a powerhouse system to run Simulator tests. It needs some dedicated cores if possible.


Wow; tests are running - It's launched the app... There's a really long splash screen... not sure if it's the simulator or the app - The test looks like it'll fail waiting for a control to show up.
It's logging that XCTRunner[40251]: Enqueue Failure: UI Testing Failure - which has me waiting for the test to fail in IntelliJ... or it'll try to run the test again? I don't really know what's happening - Things. Things are happening. HAHAHA - It flagged the app as SLOW. Had to click on a dialog box to clear it for the test to continue.

The test ran; it failed; but it ran... Took 13 minutes to run.... but run it did!
I'm running it again. I'm hoping round 2 doesn't take as long.
So far the simulator seems to be coming online faster.

HAHAHAHA! IT WORKED!

THE TEST PASSED!!!
All I did was write put text in a text box... BUT IT WORKED!!!

I'm kinda amazed. I'm THRILLED, but also amazed.


That's all I'm going to have for this TagAlong. It's a hackfest of madness; but in the end; the test ran successfully.

Show Comments