SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Android UI Testing
Luke Maung, 2015
Introduction : Luke Maung
Background in mobile / automation
● wrote mobile browser automation system for feature-
phones (Palmsource, 2004+)
● wrote distributed browser UI automation system with
Selenium/WebDriver (Yahoo! 2008+)
● Continuous Integration software engineer (LinkedIn,
2010+)
● Advise automation strategy to start-ups (2011+)
Introduction : Android Automation
● Concepts
● Setup that you can replicate easily
● Common automation use cases
UI Automation Tools - Maturity
Created Latest
Version
Sponsor Committers Commits Automation
Language
Robotium 2010 5.3.1 Google 33 1121 Java
Calabash 2013 0.5.8 Xamarin 56 1361 Ruby
Appium 2013 1.3.1 Saucelabs 139 5423 Multiple
Espresso 2013 2.0 Google 40+ ? Java
UI Automation Tools - Popularity
Appium : Benefits
1. Tests unmodified App
2. Works well on device and emulator
3. Uses well-defined WebDriver protocol
○ WebDriver is de facto standard for UI automation
○ extensive documentation
4. Good balance of low-level features and abstraction
○ can use any test framework (junit, testng, etc)
○ does not force specific test framework (eg calabash implies cucumber
framework)
5. Saucelabs very actively supports Appium
Architecture : Physical View
Test Driver Appium Server App Under Test
Architecture : Logical View
test runner
test script
webdriver
node server
appium.js
uiautomator
Bootstrap
Android
App
:4723 :4724
Test Driver Appium Server App Under Test
adb.js
adb
Setup: Install Tools
Gradle @ http://www.eng.lsu.edu/mirrors/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.zip
● GRADLE_HOME=E:gradle
● Add %GRADLE_HOME%bin to PATH
ADT @ https://developer.android.com/sdk/installing/index.html
● ANDROID_HOME = E:UserslukemaungAppDataLocalAndroidsdk
● Add %ANDROID_HOME%bin to PATH
● Create and save an emulator image, eg “android”
Appium Server
● node.js : http://nodejs.org/download/
● appium : npm install -g appium
● appium --device-name <device id> --avd <avd name> --address <ip> --port <port>
Sample Test Development
Environment
TEST DEVELOPMENT
APPIUM SERVER
EMULATOR
(RUNS APP UNDER TEST)
Setup Test Development Environment
1. create dir app/src/test/java
2. create test.gradle build config
3. add SwipeableWebDriver
4. add sample test script
Create Test Script Build Configuration
test.gradle:
apply plugin: 'java'
repositories {
mavenCentral()
}
ext.seleniumVersion = '2.45.0'
sourceSets {
main {
java {
srcDir 'src/java/'
exclude '**/**'
}
}
}
dependencies {
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version:seleniumVersion
testCompile group: 'junit', name: 'junit', version: '4.+'
}
Create Android Driver
import java.net.URL;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.interactions.*;
import org.openqa.selenium.remote.*;
public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {
private RemoteTouchScreen touch;
public SwipeableWebDriver() { }
public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {
super(remoteAddress, desiredCapabilities);
touch = new RemoteTouchScreen(getExecuteMethod());
}
public TouchScreen getTouch() {
return touch;
}
}
Test Script Part 1: Setup Appium Session
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", "<path-to-apk>");
WebDriver driver = new SwipeableWebDriver(
new URL("http://<host-name>:4723/wd/hub"), capabilities);
Test Script Part 2: Perform Navigation
1. Get a reference to the element:
○ WebElement e1 = driver.findElementBy.id, <id>)
○ WebElement e2 = driver.findElement(By.name, <content-desc>)
○ WebElement e3 = driver.findElement(By.xpath, <xpath>)
2. Invoke UI operation:
○ e1.click()
○ e2.sendKeys(“john doe”)
Test Script: Complete
public class AndroidTest extends TestCase {
public void testSomething() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", "E:/Dev/workspace/ApiDemos.apk");
WebDriver driver = new SwipeableWebDriver(
new URL("http://localhost:4723/wd/hub"), capabilities);
Thread.sleep(5000);
driver.findElement(By.xpath("//*[@text='Animation']")).click();
driver.findElement(By.xpath("//*[@text='Cloning']")).click();
WebElement runButton = driver.findElement(By.xpath("//*[@text='Run']"));
assertTrue(runButton.isDisplayed());
runButton.click();
}
}
Run Tests
1. Launch Appium:
○ appium --avd android --session-override --log-level info
2. Run Tests:
○ gradle -b test.gradle cleanTest test
App
Android
uiautomator
Bootstrap
adb
adb.js
appium.jswebdriver
test script
test runner
What Just Happened?
node server
:4724
Test Launcher Appium Server App Under Test
1) copy bootstrap.jar
3) run
uiautomator
2) install app and launch
:4723start-session()
Advanced Navigation: Gestures
Initialize touch action:
● TouchActions touchScreen = new TouchActions(driver)
Common gestures:
● touchScreen.flick(10, 0).perform() // swipe right
● touchScreen.flick(0, -10).perform() // swipe up
● touchScreen.doubleTap(elem).perform() // double tap
Locating Elements: ADT monitor
cd c:adtsdktools
monitor
click Dump View
Hiearchy button
Locating Elements: Techniques
1. Resource-id: By.id()
○ eg: By.id(“com.company.appName:id/ButtonSignIn”)
2. content-desc: By.name()
○ eg: By.name(“Downloads”)
3. Fallback: By.xpath()
○ eg: By.xpath("//*[@text='Animation']")
Test Script : Asserting Outcome
Common queries:
● e1.isDisplayed()
● e1.getText()
take screenshots
● File image = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
junit/testng asserts
● Assert.assertEquals(e1.getText(), “welcome”);
Common Pitfalls and Solutions
3 major classes of problems that break tests
1. Timing issues
○ write help methods to wrap findElementBy() with robust
wait/retry/FluentWait
○ do not use sleep. Performance variance is high
2. Many opportunities to fail from client to App
○ use full-reset launch option on Appium
○ kill adb between tests
3. Slow emulator
○ http://www.genymotion.com/
○ Use real device
Summary
You now know:
● A popular automation tool
● How it works
● How to set it up
● Typical test code
Next Step: Try it out! Ask questions!
Q&A

Weitere ähnliche Inhalte

Was ist angesagt?

Cross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToCross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToGlobalLogic Ukraine
 
Appium basics
Appium basicsAppium basics
Appium basicsSyam Sasi
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Sauce Labs
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using AppiumMindfire Solutions
 
Testing Native iOS Apps with Appium
Testing Native iOS Apps with AppiumTesting Native iOS Apps with Appium
Testing Native iOS Apps with AppiumSauce Labs
 
Mobile Automation with Appium
Mobile Automation with AppiumMobile Automation with Appium
Mobile Automation with AppiumManoj Kumar Kumar
 
Appium@Work at PAYBACK
Appium@Work at PAYBACKAppium@Work at PAYBACK
Appium@Work at PAYBACKMarcel Gehlen
 
Future of Mobile Automation, Appium Steals it
Future of Mobile Automation, Appium Steals itFuture of Mobile Automation, Appium Steals it
Future of Mobile Automation, Appium Steals itSrinivasan Sekar
 
Automation Testing With Appium
Automation Testing With AppiumAutomation Testing With Appium
Automation Testing With AppiumKnoldus Inc.
 
Mobile Test Automation - Appium
Mobile Test Automation - AppiumMobile Test Automation - Appium
Mobile Test Automation - AppiumMaria Machlowska
 
Selenium, Appium, and Robots!
Selenium, Appium, and Robots!Selenium, Appium, and Robots!
Selenium, Appium, and Robots!hugs
 
Wheat - Mobile functional test automation
Wheat - Mobile functional test automationWheat - Mobile functional test automation
Wheat - Mobile functional test automationSunny Tambi
 
Appium meet up noida
Appium meet up noidaAppium meet up noida
Appium meet up noidaAmit Rawat
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Bitbar
 
Mobile automation – should I use robotium or calabash or appium?
Mobile automation – should I use robotium or calabash or appium?Mobile automation – should I use robotium or calabash or appium?
Mobile automation – should I use robotium or calabash or appium?Zado Technologies
 
Parallel testing with appium
Parallel testing with appiumParallel testing with appium
Parallel testing with appiummoizjv
 

Was ist angesagt? (20)

Appium overview
Appium overviewAppium overview
Appium overview
 
Cross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToCross Platform Appium Tests: How To
Cross Platform Appium Tests: How To
 
Appium basics
Appium basicsAppium basics
Appium basics
 
Automated UI Testing Frameworks
Automated UI Testing FrameworksAutomated UI Testing Frameworks
Automated UI Testing Frameworks
 
Appium
AppiumAppium
Appium
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using Appium
 
Testing Native iOS Apps with Appium
Testing Native iOS Apps with AppiumTesting Native iOS Apps with Appium
Testing Native iOS Apps with Appium
 
Mobile Automation with Appium
Mobile Automation with AppiumMobile Automation with Appium
Mobile Automation with Appium
 
Appium
AppiumAppium
Appium
 
Appium@Work at PAYBACK
Appium@Work at PAYBACKAppium@Work at PAYBACK
Appium@Work at PAYBACK
 
Future of Mobile Automation, Appium Steals it
Future of Mobile Automation, Appium Steals itFuture of Mobile Automation, Appium Steals it
Future of Mobile Automation, Appium Steals it
 
Automation Testing With Appium
Automation Testing With AppiumAutomation Testing With Appium
Automation Testing With Appium
 
Mobile Test Automation - Appium
Mobile Test Automation - AppiumMobile Test Automation - Appium
Mobile Test Automation - Appium
 
Selenium, Appium, and Robots!
Selenium, Appium, and Robots!Selenium, Appium, and Robots!
Selenium, Appium, and Robots!
 
Wheat - Mobile functional test automation
Wheat - Mobile functional test automationWheat - Mobile functional test automation
Wheat - Mobile functional test automation
 
Appium meet up noida
Appium meet up noidaAppium meet up noida
Appium meet up noida
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?
 
Mobile automation – should I use robotium or calabash or appium?
Mobile automation – should I use robotium or calabash or appium?Mobile automation – should I use robotium or calabash or appium?
Mobile automation – should I use robotium or calabash or appium?
 
Parallel testing with appium
Parallel testing with appiumParallel testing with appium
Parallel testing with appium
 

Andere mochten auch

모바일 게임 테스트 자동화 (Appium 확장)
모바일 게임 테스트 자동화 (Appium 확장)모바일 게임 테스트 자동화 (Appium 확장)
모바일 게임 테스트 자동화 (Appium 확장)Jongwon Kim
 
Appium: Automation for Mobile Apps
Appium: Automation for Mobile AppsAppium: Automation for Mobile Apps
Appium: Automation for Mobile AppsSauce Labs
 
Getting Started with Mobile Test Automation & Appium
Getting Started with Mobile Test Automation & AppiumGetting Started with Mobile Test Automation & Appium
Getting Started with Mobile Test Automation & AppiumSauce Labs
 
Android Automation Testing with Selendroid
Android Automation Testing with SelendroidAndroid Automation Testing with Selendroid
Android Automation Testing with SelendroidVikas Thange
 
테스트자동화 성공전략
테스트자동화 성공전략테스트자동화 성공전략
테스트자동화 성공전략SangIn Choung
 
Ui test 자동화하기 - Selenium + Jenkins
Ui test 자동화하기 - Selenium + JenkinsUi test 자동화하기 - Selenium + Jenkins
Ui test 자동화하기 - Selenium + JenkinsChang Hak Yeon
 
Tech Talk #5 : KIF-iOS Integration Testing Framework - Nguyễn Hiệp
Tech Talk #5 : KIF-iOS Integration Testing Framework - Nguyễn HiệpTech Talk #5 : KIF-iOS Integration Testing Framework - Nguyễn Hiệp
Tech Talk #5 : KIF-iOS Integration Testing Framework - Nguyễn HiệpNexus FrontierTech
 
Automated UI testing for iOS apps using KIF framework and Swift
Automated UI testing for iOS apps using KIF framework and SwiftAutomated UI testing for iOS apps using KIF framework and Swift
Automated UI testing for iOS apps using KIF framework and SwiftJurgis Kirsakmens
 
Cross platform test automation using Appium
Cross platform test automation using AppiumCross platform test automation using Appium
Cross platform test automation using AppiumJatin Bhasin
 
iOS Testing With Appium at Gilt
iOS Testing With Appium at GiltiOS Testing With Appium at Gilt
iOS Testing With Appium at GiltGilt Tech Talks
 
Appium - test automation for mobile apps
Appium - test automation for mobile appsAppium - test automation for mobile apps
Appium - test automation for mobile appsAleksejs Trescalins
 
Appium: Mobile Automation Made Awesome
Appium: Mobile Automation Made AwesomeAppium: Mobile Automation Made Awesome
Appium: Mobile Automation Made AwesomeNetcetera
 
Android automation tools
Android automation toolsAndroid automation tools
Android automation toolsSSGMCE SHEGAON
 
Best Practices in Mobile CI (webinar)
Best Practices in Mobile CI (webinar)Best Practices in Mobile CI (webinar)
Best Practices in Mobile CI (webinar)Sauce Labs
 
Testing Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid CloudTesting Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid CloudBitbar
 
iOS and Android Acceptance Testing with Calabash - Xcake Dublin
iOS and Android Acceptance Testing with Calabash - Xcake DubliniOS and Android Acceptance Testing with Calabash - Xcake Dublin
iOS and Android Acceptance Testing with Calabash - Xcake Dublinroland99
 
TestWorksConf: Exploratory Testing an API in Mob
TestWorksConf: Exploratory Testing an API in Mob TestWorksConf: Exploratory Testing an API in Mob
TestWorksConf: Exploratory Testing an API in Mob Maaret Pyhäjärvi
 
모바일 앱(App) 개발 테스트 솔루션 v20160415
모바일 앱(App) 개발 테스트 솔루션 v20160415모바일 앱(App) 개발 테스트 솔루션 v20160415
모바일 앱(App) 개발 테스트 솔루션 v20160415SeungBeom Ha
 

Andere mochten auch (20)

모바일 게임 테스트 자동화 (Appium 확장)
모바일 게임 테스트 자동화 (Appium 확장)모바일 게임 테스트 자동화 (Appium 확장)
모바일 게임 테스트 자동화 (Appium 확장)
 
Appium: Automation for Mobile Apps
Appium: Automation for Mobile AppsAppium: Automation for Mobile Apps
Appium: Automation for Mobile Apps
 
Getting Started with Mobile Test Automation & Appium
Getting Started with Mobile Test Automation & AppiumGetting Started with Mobile Test Automation & Appium
Getting Started with Mobile Test Automation & Appium
 
Android Automation Testing with Selendroid
Android Automation Testing with SelendroidAndroid Automation Testing with Selendroid
Android Automation Testing with Selendroid
 
테스트자동화 성공전략
테스트자동화 성공전략테스트자동화 성공전략
테스트자동화 성공전략
 
Ui test 자동화하기 - Selenium + Jenkins
Ui test 자동화하기 - Selenium + JenkinsUi test 자동화하기 - Selenium + Jenkins
Ui test 자동화하기 - Selenium + Jenkins
 
Tech Talk #5 : KIF-iOS Integration Testing Framework - Nguyễn Hiệp
Tech Talk #5 : KIF-iOS Integration Testing Framework - Nguyễn HiệpTech Talk #5 : KIF-iOS Integration Testing Framework - Nguyễn Hiệp
Tech Talk #5 : KIF-iOS Integration Testing Framework - Nguyễn Hiệp
 
Automated UI testing for iOS apps using KIF framework and Swift
Automated UI testing for iOS apps using KIF framework and SwiftAutomated UI testing for iOS apps using KIF framework and Swift
Automated UI testing for iOS apps using KIF framework and Swift
 
Cross platform test automation using Appium
Cross platform test automation using AppiumCross platform test automation using Appium
Cross platform test automation using Appium
 
iOS Testing With Appium at Gilt
iOS Testing With Appium at GiltiOS Testing With Appium at Gilt
iOS Testing With Appium at Gilt
 
Appium
AppiumAppium
Appium
 
Appium - test automation for mobile apps
Appium - test automation for mobile appsAppium - test automation for mobile apps
Appium - test automation for mobile apps
 
Appium: Mobile Automation Made Awesome
Appium: Mobile Automation Made AwesomeAppium: Mobile Automation Made Awesome
Appium: Mobile Automation Made Awesome
 
Android automation tools
Android automation toolsAndroid automation tools
Android automation tools
 
Best Practices in Mobile CI (webinar)
Best Practices in Mobile CI (webinar)Best Practices in Mobile CI (webinar)
Best Practices in Mobile CI (webinar)
 
Testing Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid CloudTesting Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid Cloud
 
Mob Testing
Mob TestingMob Testing
Mob Testing
 
iOS and Android Acceptance Testing with Calabash - Xcake Dublin
iOS and Android Acceptance Testing with Calabash - Xcake DubliniOS and Android Acceptance Testing with Calabash - Xcake Dublin
iOS and Android Acceptance Testing with Calabash - Xcake Dublin
 
TestWorksConf: Exploratory Testing an API in Mob
TestWorksConf: Exploratory Testing an API in Mob TestWorksConf: Exploratory Testing an API in Mob
TestWorksConf: Exploratory Testing an API in Mob
 
모바일 앱(App) 개발 테스트 솔루션 v20160415
모바일 앱(App) 개발 테스트 솔루션 v20160415모바일 앱(App) 개발 테스트 솔루션 v20160415
모바일 앱(App) 개발 테스트 솔루션 v20160415
 

Ähnlich wie Android UI Testing with Appium

Using protractor to build automated ui tests
Using protractor to build automated ui testsUsing protractor to build automated ui tests
Using protractor to build automated ui tests🌱 Dale Spoonemore
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with exampleshadabgilani
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
探討Web ui自動化測試工具
探討Web ui自動化測試工具探討Web ui自動化測試工具
探討Web ui自動化測試工具政億 林
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to proDomenico Gemoli
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterBoni García
 
MDC2011 Android_ Webdriver Automation Test
MDC2011 Android_ Webdriver Automation TestMDC2011 Android_ Webdriver Automation Test
MDC2011 Android_ Webdriver Automation TestMasud Parvez
 
Setting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with AppiumSetting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with Appiummobiletestsummit
 
Introduction to Selenium and WebDriver
Introduction to Selenium and WebDriverIntroduction to Selenium and WebDriver
Introduction to Selenium and WebDriverTechWell
 
Protractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine ReportersProtractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine ReportersHaitham Refaat
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introductionvstorm83
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Selenium Testing with TestingBot.com
Selenium Testing with TestingBot.comSelenium Testing with TestingBot.com
Selenium Testing with TestingBot.comtestingbot
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor🌱 Dale Spoonemore
 
Mobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructureMobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructureMichael Palotas
 

Ähnlich wie Android UI Testing with Appium (20)

Using protractor to build automated ui tests
Using protractor to build automated ui testsUsing protractor to build automated ui tests
Using protractor to build automated ui tests
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with example
 
Selenium
SeleniumSelenium
Selenium
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Browser_Stack_Intro
Browser_Stack_IntroBrowser_Stack_Intro
Browser_Stack_Intro
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
探討Web ui自動化測試工具
探討Web ui自動化測試工具探討Web ui自動化測試工具
探討Web ui自動化測試工具
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to pro
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
 
MDC2011 Android_ Webdriver Automation Test
MDC2011 Android_ Webdriver Automation TestMDC2011 Android_ Webdriver Automation Test
MDC2011 Android_ Webdriver Automation Test
 
Setting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with AppiumSetting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with Appium
 
Introduction to Selenium and WebDriver
Introduction to Selenium and WebDriverIntroduction to Selenium and WebDriver
Introduction to Selenium and WebDriver
 
test_automation_POC
test_automation_POCtest_automation_POC
test_automation_POC
 
Protractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine ReportersProtractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine Reporters
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Selenium Testing with TestingBot.com
Selenium Testing with TestingBot.comSelenium Testing with TestingBot.com
Selenium Testing with TestingBot.com
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor
 
Mobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructureMobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructure
 

Kürzlich hochgeladen

Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPsychicRuben LoveSpells
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Pooja Nehwal
 
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceanilsa9823
 
9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7Pooja Nehwal
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRnishacall1
 
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceanilsa9823
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 

Kürzlich hochgeladen (7)

Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
 
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
 
9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
 

Android UI Testing with Appium

  • 2. Introduction : Luke Maung Background in mobile / automation ● wrote mobile browser automation system for feature- phones (Palmsource, 2004+) ● wrote distributed browser UI automation system with Selenium/WebDriver (Yahoo! 2008+) ● Continuous Integration software engineer (LinkedIn, 2010+) ● Advise automation strategy to start-ups (2011+)
  • 3. Introduction : Android Automation ● Concepts ● Setup that you can replicate easily ● Common automation use cases
  • 4. UI Automation Tools - Maturity Created Latest Version Sponsor Committers Commits Automation Language Robotium 2010 5.3.1 Google 33 1121 Java Calabash 2013 0.5.8 Xamarin 56 1361 Ruby Appium 2013 1.3.1 Saucelabs 139 5423 Multiple Espresso 2013 2.0 Google 40+ ? Java
  • 5. UI Automation Tools - Popularity
  • 6. Appium : Benefits 1. Tests unmodified App 2. Works well on device and emulator 3. Uses well-defined WebDriver protocol ○ WebDriver is de facto standard for UI automation ○ extensive documentation 4. Good balance of low-level features and abstraction ○ can use any test framework (junit, testng, etc) ○ does not force specific test framework (eg calabash implies cucumber framework) 5. Saucelabs very actively supports Appium
  • 7. Architecture : Physical View Test Driver Appium Server App Under Test
  • 8. Architecture : Logical View test runner test script webdriver node server appium.js uiautomator Bootstrap Android App :4723 :4724 Test Driver Appium Server App Under Test adb.js adb
  • 9. Setup: Install Tools Gradle @ http://www.eng.lsu.edu/mirrors/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.zip ● GRADLE_HOME=E:gradle ● Add %GRADLE_HOME%bin to PATH ADT @ https://developer.android.com/sdk/installing/index.html ● ANDROID_HOME = E:UserslukemaungAppDataLocalAndroidsdk ● Add %ANDROID_HOME%bin to PATH ● Create and save an emulator image, eg “android” Appium Server ● node.js : http://nodejs.org/download/ ● appium : npm install -g appium ● appium --device-name <device id> --avd <avd name> --address <ip> --port <port>
  • 10. Sample Test Development Environment TEST DEVELOPMENT APPIUM SERVER EMULATOR (RUNS APP UNDER TEST)
  • 11. Setup Test Development Environment 1. create dir app/src/test/java 2. create test.gradle build config 3. add SwipeableWebDriver 4. add sample test script
  • 12. Create Test Script Build Configuration test.gradle: apply plugin: 'java' repositories { mavenCentral() } ext.seleniumVersion = '2.45.0' sourceSets { main { java { srcDir 'src/java/' exclude '**/**' } } } dependencies { compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version:seleniumVersion testCompile group: 'junit', name: 'junit', version: '4.+' }
  • 13. Create Android Driver import java.net.URL; import org.openqa.selenium.Capabilities; import org.openqa.selenium.interactions.*; import org.openqa.selenium.remote.*; public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen { private RemoteTouchScreen touch; public SwipeableWebDriver() { } public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) { super(remoteAddress, desiredCapabilities); touch = new RemoteTouchScreen(getExecuteMethod()); } public TouchScreen getTouch() { return touch; } }
  • 14. Test Script Part 1: Setup Appium Session DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName","Android Emulator"); capabilities.setCapability("platformName","Android"); capabilities.setCapability("app", "<path-to-apk>"); WebDriver driver = new SwipeableWebDriver( new URL("http://<host-name>:4723/wd/hub"), capabilities);
  • 15. Test Script Part 2: Perform Navigation 1. Get a reference to the element: ○ WebElement e1 = driver.findElementBy.id, <id>) ○ WebElement e2 = driver.findElement(By.name, <content-desc>) ○ WebElement e3 = driver.findElement(By.xpath, <xpath>) 2. Invoke UI operation: ○ e1.click() ○ e2.sendKeys(“john doe”)
  • 16. Test Script: Complete public class AndroidTest extends TestCase { public void testSomething() throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName","Android Emulator"); capabilities.setCapability("platformName","Android"); capabilities.setCapability("app", "E:/Dev/workspace/ApiDemos.apk"); WebDriver driver = new SwipeableWebDriver( new URL("http://localhost:4723/wd/hub"), capabilities); Thread.sleep(5000); driver.findElement(By.xpath("//*[@text='Animation']")).click(); driver.findElement(By.xpath("//*[@text='Cloning']")).click(); WebElement runButton = driver.findElement(By.xpath("//*[@text='Run']")); assertTrue(runButton.isDisplayed()); runButton.click(); } }
  • 17. Run Tests 1. Launch Appium: ○ appium --avd android --session-override --log-level info 2. Run Tests: ○ gradle -b test.gradle cleanTest test
  • 18. App Android uiautomator Bootstrap adb adb.js appium.jswebdriver test script test runner What Just Happened? node server :4724 Test Launcher Appium Server App Under Test 1) copy bootstrap.jar 3) run uiautomator 2) install app and launch :4723start-session()
  • 19. Advanced Navigation: Gestures Initialize touch action: ● TouchActions touchScreen = new TouchActions(driver) Common gestures: ● touchScreen.flick(10, 0).perform() // swipe right ● touchScreen.flick(0, -10).perform() // swipe up ● touchScreen.doubleTap(elem).perform() // double tap
  • 20. Locating Elements: ADT monitor cd c:adtsdktools monitor click Dump View Hiearchy button
  • 21. Locating Elements: Techniques 1. Resource-id: By.id() ○ eg: By.id(“com.company.appName:id/ButtonSignIn”) 2. content-desc: By.name() ○ eg: By.name(“Downloads”) 3. Fallback: By.xpath() ○ eg: By.xpath("//*[@text='Animation']")
  • 22. Test Script : Asserting Outcome Common queries: ● e1.isDisplayed() ● e1.getText() take screenshots ● File image = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); junit/testng asserts ● Assert.assertEquals(e1.getText(), “welcome”);
  • 23. Common Pitfalls and Solutions 3 major classes of problems that break tests 1. Timing issues ○ write help methods to wrap findElementBy() with robust wait/retry/FluentWait ○ do not use sleep. Performance variance is high 2. Many opportunities to fail from client to App ○ use full-reset launch option on Appium ○ kill adb between tests 3. Slow emulator ○ http://www.genymotion.com/ ○ Use real device
  • 24. Summary You now know: ● A popular automation tool ● How it works ● How to set it up ● Typical test code Next Step: Try it out! Ask questions!
  • 25. Q&A