Appium and Selendroid
Desired Capabilities
UI Automator and Challenges faced in finding elements
Wait & Handling Keyboard
Touch Actions and Wait Actions
Android Key Events
Android and iOS Scenarios
Overall Flow using an e-Commerce app
Alternative Solution of Appium
Pros and Cons of Appium
2. www.tothenew.com
Appium: Let’s enjoy Open Source
Open Source, Cross platform test
automation tool to test mobile
application
Based on Client-Server Architecture
using Webdriver
Established in January 2011
Dan Cuellar, Jonathan Lipps & Others
Contributors
Supports Native , Hybrid and
Mobile Web apps
Supports Both Android and iOS
Appium.io
4. www.tothenew.com
Agenda:-
Areas We Cover
Appium Locators Android Actions
Desired Capabilities How to use UI Automator? Click, SendKeys
Android Key Events Mobile Gestures Demo
Home , Back , Enter, Click Camera Swipe, Scroll, Tap Test Case Execution Report
5. www.tothenew.com
Coverage
Appium - Recall Previous Session
Appium and Selendroid
Desired Capabilities
UI Automator and Challenges faced in finding elements
Wait & Handling Keyboard
Touch Actions and Wait Actions
Android Key Events
Android and iOS Scenarios
Overall Flow using an e-Commerce app
Alternative Solution of Appium
Pros and Cons of Appium
6. www.tothenew.com
Basic Requirements for Appium
Appium is an open source, cross-platform test automation tool for native,
hybrid and mobile web apps, tested on simulators ,emulators and real
devices.
iOS Requirements
•Mac OS
•xCode
•Apple Developer Tools (iPhone simulator SDK)
Android Requirements
•Android SDK, Java
Appium supports Android on OS X, Linux and Windows. So setup
accordingly
7. www.tothenew.com
Appium in a Nutshell
APPIUM is a freely distributed open source mobile application UI testing
framework.
Appium allows native, hybrid and web application testing and supports automation
test on physical devices as well as on emulator or simulator both.
It offers cross-platform application testing i.e. single API works for both Android
and iOS platform test scripts.
It has NO dependency on Mobile device OS. Because, APPIUM has framework or
wrapper that translate Selenium Webdriver commands into UIAutomation (iOS) or
UIAutomator (Android) commands depending on the device type not any OS type.
Appium supports all languages that have Selenium client libraries like- Java,
Objective-C, JavaScript with node.js, PHP, Ruby, Python, C# etc.
8. www.tothenew.com
Appium Vs. Selendroid
Appium and Selendroid are quite similar :-
both use Selenium WebDriver and used for native, hybrid and mobile web apps
both could run tests on emulator or real devices
both are suitable for Cloud Based Testing
Appium supports all Android API levels but there is one limitation. As it uses
UIAutomator for tests running on API>=17, for older APIs you need to run tests using
Selendroid.
Selendroid or “Selenium for Android” is a test automation framework which is used
ONLY for Android apps. Where as Appium is a open source automation tool used for
Android, iOS and Firefox OS too.
Selendroid has multiple Android target API support (10 to 19) and it has no limitation
with WebView testing like Appium which uses UIAutomator for API>=17.
9. www.tothenew.com
Desired Capabilities
Desired Capabilities are a set of keys and values sent to the Appium server to tell the
server what kind of automation session we’re interested in starting up.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, “”);
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(CapabilityType.VERSION, “4.4”);
capabilities.setCapability(“deviceName”, “111bd508”);
capabilities.setCapability(“app”, app.getAbsolutePath());
capabilities.setCapability(“appPackage”, “com.example.android.contactmanager”);
capabilities.setCapability(“appActivity”, “.ContactManager”);
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
10. www.tothenew.com
UI Automator
Go to SDK folder and open the tools folder.
Open UIAutomatorViewer.
On the actual device, open the app to the page you want to automate.
In UI Automator Viewer, click on Device screenshot (second button).
Click any element on the page and look in the Node detail window (there
you will find details about the selected element: id, class, name, etc.)
Use the info found (id, class) in Eclipse to click buttons, fill input fields
11. www.tothenew.com
Mobile Keyboard Events Used in Mobile Automation
public static final int KEYCODE_ENTER
Key code constant: Enter key.
Constant Value: 66 (0x00000042)
public static final int KEYCODE_CAMERA
Key code constant: Camera key. Used to launch a camera
application or take pictures.
Constant Value: 27 (0x0000001b)
public static final int KEYCODE_BACK
Key code constant: Back key.
Constant Value: 4 (0x00000004)
http://developer.android.com/reference/android/view/KeyEvent.html
12. www.tothenew.com
Functions Used in Mobile Automation
Some Common Functions used in Mobile Automation :-
tap()
swipe()
pinch()
zoom()
getNamedTextField()
isAppInstalled()
installApp()
removeApp()
launchApp()
closeApp()
13. www.tothenew.com
Common Issues of Appium
error:- The following desired capabilities are required, but were not
provided:device Name, platformName
Ans. Add desired capabilities: device Name, platformName in APPIUM script.
e.g:capabilities.setCapability("deviceName","Emulator");
capabilities.setCapability("platformName","Android");
error:- Could not find adb. Please set the ANDROID_HOME environment
variable with the Android SDK root directory path.
Ans. You probably need to set up SDK root directory path in system
'Environment Variables' in 'Path' column
error:- org.openqa.selenium.SessionNotCreatedException: A new session
could not be created.
Ans. You need to set a correct App path and restart the Appium server.
14. www.tothenew.com
Advantages of Appium
Open Source Tool
Support for both platforms iOS and android.
Handles simulators/emulators and real devices
Supports automation of hybrid, native and webApps
Supports most of the programming languages like Java, Ruby,
Python, C# etc.
15. www.tothenew.com
Dis-Advantages of Appium
Alert Handling is not implemented yet for native apps via
Alert API
Appium supports Android Versions 17 or later . For lower
versions we have to use Selendroid.
Lack of Image Recognition
Limited Mobile Gesture Support.
16. www.tothenew.com
Drawbacks and Limitations of Appium
Appium does not support testing of Android Version lower than 4.2
Limited support for hybrid app testing. eg: not possible to test the
switching action of application from the web app to native and vice-
versa.
No support to run Appium Inspector on Microsoft Windows.