Menu
This is the first in a 2-part series on using real iOS devices with Appium. It's a tutorial on getting started from scratch, authored by Appium contributor Jonah Stiennon. Since getting set up with real iOS devices can be a long and involved process, this first edition will cover all the preliminary work you need to do to make sure Appium, your app, and your device will all be able to talk to each other. Stay tuned for next week when Jonah will show us how to put it all together.
Sep 02, 2019 Update OS X to at least Catalina 10.15.2. I got several issues resolve when I upgrade to the OS. Install java 1.8 latest build. You can get the latest JDK 1.8 from this link. At this time of the. Jan 23, 2020 How to install Appium Studio Community Edition (Windows or Mac): Step 1: Download the application. Step 2: Launch the installation wizard. How to install Appium Studio Enterprise Edition (Windows or Mac): Step 1: Download SeeTestAutomation. Step 2: Launch the installation wizard. When prompted, uncheck 'Run SeeTestAutomation'.
This edition of Appium Pro is about getting started with a real iOS device test starting from scratch. Real iOS device testing can only take place on a Mac. (NB: This tutorial was written with OS X v10.14, Xcode version 10.0, automating an iPhone X S running iOS version 12.0.1. While the tutorial should remain largely correct for other versions, your mileage may vary!)
Organize Our Work Area
First things first, let's clean up our workspace and get ready to start a new project. Let's make sure all our software is up to date. To begin with, check that we have the latest version of Xcode installed. Then, since we will be using Homebrew, let's run
brew update
. Next let's launch Xcode in case it hasn't been launched before. (You will need to accept the End User License Agreement and may have to click a button to 'install additional components').Next we will install libimobiledevice, an open source package which is able to communicate with iOS devices. The only official applications made by Apple for communicating with iOS devices are Xcode and iTunes. These applications weren't built to easily allow programmatic use, which is why Appium uses libimobiledevice for certain operations.
brew install libimobiledevice
Appium also uses a package called ios-deploy for transferring iOS apps onto your device, so let's install that too.
brew install ios-deploy
WDA itself requires an iOS dependency manager called Carthage. Since Appium will be automatically building the WDA app, we need to install Carthage so it is available to the WDA bootstrap process.
brew install carthage
OK, now we've installed some things that Appium needs, but let's make sure we have Appium installed as well. I'm going to install the Appium Desktop App. Download the latest
Appium-x.x.x.dmg
file from the releases page. Open the file and drag the Appium.app icon into your Applications folder.Finally, with the housecleaning on our Mac now finished, let's make sure our iOS device is set up:
- Turn the iOS device on
- Plug the device into your Mac
- Unlock the device
- Wait for a dialog to appear on the device and choose to 'Trust' the Mac
Running tests on the device will always require you to unlock it. There are parts of this process where if the device is locked, things may get into a bad state and the only way to continue will be to unplug the device and plug it back in. In order to avoid any further issues (and annoyances), let's go into the Settings app, select
Display & Brightness
, select Auto-Lock
, and set it to never
, to ensure that the screen never locks on us mid-test. (Obviously this means it's a good idea to keep your phone plugged in, and maybe set the brightness down a bit to save some electrons).Run App Manually Using Xcode
Before using Appium to run tests on our device, let's make sure we can manually run our app on the device using Xcode.Opening the Xcode workspace for the app we want to test, we choose the device we want to run the app on by clicking the icon to the right of our app name by the
▶
button in the upper left hand corner. Xcode will usually automatically select our device once plugged in, but sometimes we have to select it ourselves.My app is so new that I haven't set up Xcode with my developer profile. If you're like me, Apple will want us to register with them before I go any further. If I click the play button, it tells me I need a provisioning profile. Clicking on my app in the file browser on the left side of Xcode I'm brought to the main settings for the project.
Os x interface for windows. There's a warning sign in the 'signing' section. Select the dropdown next to
Team
choose Add an Account
. If I worked on a team with other people, at this point I'd be asking them to add me to their team which should already be set up to run this app. Sign in with our Apple ID, click on 'manage certificates' and click the +
button to add a new certificate. Xcode is helpful and handles the rest. Now we can go back to our app settings page and choose our name from the dropdown.The certificate we created has an important piece of information we will need later. We need the 'Organizational Unit' which is a way to identify our development team. Let's open the Keychain Access app on our Mac and choose
My Certificates
in the lower lefthand corner. Now the main panel will display our new developer certificate. Double-click on the certificate we just created to see its details. Make a note of the ten digit ID next to Organizational Unit
.Going back to Xcode, clicking the
▶
button again in the upper lefthand corner will attempt to run our app on the device, but another error is logged.Xcode is telling us that in order for the device to run our app, the device has to trust our developer certificate. Normally, an iOS device will only run apps from the App Store. An app which is placed on the device but didn't come from the app store could be malicious. The device checks the certificate that the app was compiled with and will only trust official app store certificates. If we look at our device, we can see the app has been installed, it is only when the device tries to run the app that we encounter this error. As an interesting experiment, try manually tapping on the app on the device, this time the device (rather than Xcode) tries to instruct us how to trust the certificate.
We want the device to trust our certificate which we added to Xcode in the previous step, so now we will tell the device to trust it. Let's do exactly as it instructed, open the
Settings
app on the device, tap on General
, tap on Device Management
and pick the Developer App Certificate which we created earlier.Then tap the blue link to trust the app we're trying to test.
By clicking the
▶
button in Xcode, the app now runs on our device!There is a rather confusing issue I ran into, where Xcode asks us for our password while building our app. Typing the wrong password will cause the alert to shake disagreeably, but typing the correct password and hitting the
return
key seems to do nothing.The sneaky issue going on here is that the default button activated by the
return
key is Allow
, but we actually want to click Always Allow
. Accidentally choosing Allow
results in an identical popup appearing immediately. Dragging the window reveals another window underneath it. I really got myself into a mess this way.Don't worry, the simple but annoying solution is to patiently type your password and click
Always Allow
over and over until you work your way through all windows.At this point, we have:
- Gotten a fresh set of system dependencies
- Linked our device with Xcode
- Linked our developer account with Xcode
- Linked our device with the developer certificate used to sign our app
- Launched our app manually on our device
Assuming this has all worked, we will be in good shape for Appium to automate our app. In the next edition in this series, we'll look at how exactly Appium ends up controlling your app, and the unique capabilities required to make it all work.
This is the first blog in our Things You Should Know About Appium blog series, and we’ll naturally start with the basic things, getting the environment set up, Appium pieces installed and running on your machine. Depending on which programming language you are using, we’ve tried to provide here everything, step-by-step, for those 4 main languages to get you started with Appium tests.
To get started, first download our sample Appium tests. The example is available in C#, Python, Java and Ruby, and we’ll be using these as a basis for the next examples. Okay, then depending on which programming language you will be using, select the appropriate client library as follows. Or you can download our free Appium beginner’s guide to access your local copy anytime.
Most of the Testdroid examples are located in our Github repositories. To make most out of the existing samples you should have Git installed. If you are new to Git, there is a very good guide on how to install Git on a popular operating system here. Below is the abbreviated version of the installation procedures.
Mac OS X
Download the latest git command-line tool from http://git-scm.com/download/macinstall it using normal Mac installation procedure.
Linux
Appium Download For Mac Os X 10 13 Download
Use the following command to get Git installed on your Linux machine:
Windows
The easiest and most straight forward way is to install the Github Windows application.
Python
Mac OS X and Linux
Our Python samples have been created with the 2.7.x version in use, so best compatibility can be expected with the same. Check that the newest Python 2.7.x version is installed by using the following command:
How To Install Appium
If not installed, you can install Python by using the following commands:
Brew is a handy package manager tool, similar to apt-get. If you don’t have it, check the brew website for its one-liner installation.
Then, check if ‘pip’ module is installed. Use the following command:
Then, check if ‘pip’ module is installed. Use the following command:
If ‘pip’ is appropriately installed, you’ll see something like this:
pip 1.5.6 from /Library/Python/2.7/site-packages (Python 2.7)
If not, use the following command to install it:
Next, install the Selenium module for Python:
And finally, verify that Selenium got installed:
Windows
Ensure that the newest Python 2.7.x version is installed. Go to the command line and use the following:
If Python 2.7 or newer is not installed, download and run the setup from Python’s download center. To add Python into environment variables, go to Windows “System properties” → “Advanced System Settings” → “Environment Variables” → “System Variables” → choose “Path” and press “Edit…” and then insert (assuming you have installed Python in the default location)
;C:Python27;C:Python27Scripts
at the end separating each path with a semicolon. Make sure to re-launch the command prompt to bring new environment variables into effect.Then, check whether Python’s pip module is already installed:
Install pip if it’s not already (we assume here that you have cURL installed. If not, check this out):
Install Python’s Selenium module:
Java
Appium testing supports writing tests in multiple programming languages, including Java. Testing can be done against native or hybrid apps or responsive web pages on both iOS and Android devices. Only the test setups differ.
With Java, things are pretty simple and you only need to configure your test file accordingly. You can use SampleAppium(iOS)Test.java as an example/template.
In case you don’t have an IDE with Maven included and would like to launch the example from the command line, you will need to make sure that Maven is properly installed. Here’s a link to the installation instructions.
C#
Windows
Launch the AppiumTest.sln on Visual Studio and make sure that the NUnit Test Adapter is installed through the Extension Manager. Use Test Explorer to run your tests.
Linux/OSX
First, install Monodevelop for C# support. Then, download dependencies using Nuget:
To build the package, simply use the following command on the correct path:
Ruby
First, install the latest stable release of Ruby:
Then, make sure RVM is using the correct Ruby by default:
In case you have an old Ruby/RVM, you can upgrade those with the following commands:
Check that it’s installed properly by printing out the Ruby version:
Update RubyGems and Bundler:
Check that RubyGems is >= 2.1.5
Run bundler at the Ruby example directory to install dependencies:
All Programming Languages: How to Configure Specific Settings
If you used any of those example files as a template, add your Bitbar user credentials in this script. You can also use environmental variables TESTDROID_USERNAME and TESTDROID_PASSWORD to get your credentials used:
Or alternatively, you can edit
testdroid_username
and testdroid_password
in your source file:If you are new with desired capabilities or if you are looking for more information on how to use those efficiently, take a look at this article.
Also, if you want to run tests against your application, make sure to change a file path to your application binary (whether you are running against APK or IPA):
In addition, there are lots of possible ways to configure your test run for our devices. In order to do this, you need to configure those desired capabilities. We’ll get the bottom of this later in the blog series, but the current examples are as follows:
In this Java example, you only really need to configure
testdroid_username
and testdroid_password
, since sample application upload is included.Running Your First Appium Tests
Before the test can start you need to upload your application to Bitbar Testing. This can be done either via API or you can do it manually as well.
Python
To upload your app file (either APK or IPA) to Bitbar Testing, open and configure the
upload.py
script. As we walked it through, you only need to configure your username (email) and password that you registered with to Bitbar Testing. Also, you need to set the full path to your mobile app. This can be an Android or iOS application. Then execute this:To run a test:
Java
You can run the test from your IDE or directly from the command line using Maven:
or to be more precise:
or run all the tests:
C#
Appium Download For Mac Os X
To run tests, either launch them in Visual Studio via the Text Explorer or use the nunit console command:
Ruby
Run the tests with rspec:
Conclusion
There’s a myriad of different ways you can set up, build and run your Appium tests. The ones provided here were just one example of how things can be done. Stay tuned – more good stuff about Appium is coming out in a few days!
Happy Appium Testing!