-
Notifications
You must be signed in to change notification settings - Fork 23
Home
Appium is an open source test automation framework for use with native, hybrid and mobile web apps. It drives iOS, Android, and Windows apps using the WebDriver protocol. Appium is built on the idea that testing native apps shouldn't require including an SDK or recompiling your app. And that you should be able to use your preferred test practices, frameworks, and tools. Appium also has made design and tool decisions to encourage a vibrant contributing community.
As a test developer, it is quite hard to create a good automated test suite that works on the iOS and Android platforms. Both Android and iOS have a couple of different test frameworks that work well but have nothing to do with each other. So you then have to create and maintain two separate test suites, one for Android and one for iOS. They are also written in different languages and with different development tools (IDEs) so even if the applications work the same it is hard to share any code between the tests for the different platforms. But this is where Appium comes in. From Appium's own website:
Appium is “cross-platform”: it allows you to write tests against multiple platforms (iOS, Android), using the same API. This enables code reuse between iOS and Android test suites.
This repository contains a minimalistic Appium Test Suite written in Java that runs a few simple tests on this Android app and this iOS app. To run the tests successfully you'll need to have the .apk and the .app file of both apps so I'd recommend having those in place before getting started here if you want to see the tests run on those apps, otherwise, this can be used as a starting point for your own Test Suite.
iOS
- Mac OSX
- XCode w/ Command Line Tools
Android
- Mac OSX or Windows or Linux
- Android SDK ≥ 16
Basically, you need to have appium installed along with appium-doctor. I won't go into a walkthrough of setting these up as there are plenty resources out there to guide you in setting up Appium to test apps on both platforms. See below for some helpful links to help you get appium and appium-doctor installed.
- http://appium.io/
- http://appium.io/slate/en/tutorial/android.html
- http://appium.io/slate/en/tutorial/ios.html
- https://github.com/appium/appium-doctor
- http://appium.io/slate/en/master/?java#
Those links should be enough to give you all the information you need about appium, appium-doctor and getting set up. Once you have everything set up remember to use appium doctor to confirm. See below how the results of your appium doctor check should look before moving on.
At this point, everything for Appium should be installed and in that process, you should've installed Apache Maven. If not take a second to install Maven.
Here's a helpful link for doing that:
To run your tests simply you need to execute the following command from inside the project directory.
mvn test
To run the sample tests you first need to set the following environment variables "ios_app_path" and "android_app_path" on your system. These need to be defined globally to be the path to the iOS .app file and Android .apk file respectively. For help setting environment variables on your system check out the following links.
- https://www.howtogeek.com/51807/how-to-create-and-use-global-system-environment-variables/ (Even though it's an outdated version of Windows in the Screenshots, the process is the same)
- https://www.cyberciti.biz/faq/set-environment-variable-unix/ (Unix and Linux Environments)
and then execute the following command from inside the project directory.
mvn test
-
Android Studio(https://developer.android.com/studio/index.html)
-
Appium Desktop. It is a graphical interface for Appium Server with flexible UI. It provides a UI Inspector which makes it easy to identify your app's elements and perform basic interactions with them, so that you can write tests for it.
- Download Appium Desktop -> https://github.com/appium/appium-desktop/releases/tag/v1.1.1
- Introduction to Appium Desktop -> https://saucelabs.com/resources/webinars/an-introduction-to-appium-desktop
-
Running Appium to test an Android App (https://www.youtube.com/watch?v=qaOwd-W5Fx4)
-
Running Appium to test an iOS App (https://www.youtube.com/watch?v=meU4TzI3KNM)
- Although the app runs in the iPhone Simulator from Xcode it doesn't run when launched from appium.
Make sure that Carthage is installed.
brew install carthage
- When running iOS apps through the simulator, ensure that all of the following desired capabilities are set.
{
deviceName: "string",
platformName: "iOS",
platformVersion: "string",
automationName: "XCUITest",
app: "string"
}
The platformVersion should be a string containing the version of the iPhone Simulator being used.
- Only the Android Command line tools are installed (Not Android Studio), however, after installing the necessary platform tools, system installs and creating an android virtual device. Running
emulator @EmulatorName
produces aLibrary Not Found
orFile or directory not found
error.
The version of the Android sdk tools you are using contains a bug. To overcome this, the emulator needs to be run directly from the installation directory. Run the following commands:
cd $ANDROID_SDK_ROOT/emulator (or your equivalent ANDROID_HOME directory)
emulator @EmulatorName
- When using the IntelliJ IDE to write your test. The run button is disabled.
Right click on the
{ProjectName}/src/test/java
folder and select run all. Additionally, if you wish to run a single test, this can be done by right clicking on the function signature of the test and selecting run {TestName}
- Since Appium requires an app file, how do I test an iOS app that I downloaded from the internet.
With the project open in Xcode, go to
Product-> Build For-> Testing
. A.app
file will be generated under theProducts
folder of the application. Selecting this file will reveal it's full path in the right hand panel of Xcode. This can be provided to Appium as the value of theapp
parameter.