SlideShare a Scribd company logo
Automated User Interface
Testing
Working while you’re at lunch

David Reidy
uTeach


                                1
UI Testing




             2
UI Testing
 Why?




             2
UI Testing
 Why?
  If we’re testing internals we should probably test
  externals




                                                       2
UI Testing
 Why?
  If we’re testing internals we should probably test
  externals
  It’s what the user sees, and that’s more important
  than how it does whatever




                                                       2
UI Testing
 Why?
  If we’re testing internals we should probably test
  externals
  It’s what the user sees, and that’s more important
  than how it does whatever
 Why not?




                                                       2
UI Testing
 Why?
  If we’re testing internals we should probably test
  externals
  It’s what the user sees, and that’s more important
  than how it does whatever
 Why not?
  It’s bloody boring the 37th time


                                                       2
Automated testing




                    3
Automated testing

Much less boring




                    3
Automated testing

Much less boring
Gives you confidence that your users’ experiences will
be as planned




                                                         3
Automated testing

Much less boring
Gives you confidence that your users’ experiences will
be as planned
Hard to forget to test something




                                                         3
Automated testing

Much less boring
Gives you confidence that your users’ experiences will
be as planned
Hard to forget to test something
Much less likely to have to issue an emergency update




                                                         3
Automated testing

Much less boring
Gives you confidence that your users’ experiences will
be as planned
Hard to forget to test something
Much less likely to have to issue an emergency update
Gives you an excuse to read xkcd comics


                                                         3
How to do it




               4
How to do it


 AUIT is part of Instruments




                               4
How to do it


 AUIT is part of Instruments
 Tests are written in JavaScript




                                   4
How to do it


 AUIT is part of Instruments
 Tests are written in JavaScript
 AUIT uses the accessibility interfaces




                                          4
How to do it


 AUIT is part of Instruments
 Tests are written in JavaScript
 AUIT uses the accessibility interfaces
 Make your app accessible and you’re half-way there




                                                      4
Demo


Test
 1
Yes, I know my coding style doesn’t match anyone else’s   5
How does it do it




                    6
How does it do it

 Your app has a DOM which is accessible using
 JavaScript




                                                6
How does it do it

 Your app has a DOM which is accessible using
 JavaScript
 The accessibilityLabel property of a UIView is the key




                                                          6
How does it do it

 Your app has a DOM which is accessible using
 JavaScript
 The accessibilityLabel property of a UIView is the key
 The automation instrument can simulate nearly all user
 interactions




                                                          6
How does it do it

 Your app has a DOM which is accessible using
 JavaScript
 The accessibilityLabel property of a UIView is the key
 The automation instrument can simulate nearly all user
 interactions
 Works with both the simulator and real device



                                                          6
accessibilityLabel




                     7
accessibilityLabel
 Using Xcode it’s available in the Utilities panel (third
 screen)




                                                            7
accessibilityLabel
 Using Xcode it’s available in the Utilities panel (third
 screen)
 Not all controls have it available in Xcode




                                                            7
accessibilityLabel
 Using Xcode it’s available in the Utilities panel (third
 screen)
 Not all controls have it available in Xcode
   e.g. UIBarButtonItem




                                                            7
accessibilityLabel
 Using Xcode it’s available in the Utilities panel (third
 screen)
 Not all controls have it available in Xcode
   e.g. UIBarButtonItem
 Available in code for all UIViews




                                                            7
accessibilityLabel
 Using Xcode it’s available in the Utilities panel (third
 screen)
 Not all controls have it available in Xcode
   e.g. UIBarButtonItem
 Available in code for all UIViews
   setAccessibilityLabel:(NSString*)label



                                                            7
accessibilityLabel
 Using Xcode it’s available in the Utilities panel (third
 screen)
 Not all controls have it available in Xcode
   e.g. UIBarButtonItem
 Available in code for all UIViews
   setAccessibilityLabel:(NSString*)label
   setIsAccessibilityElement:(BOOL)value


                                                            7
Accessibility




                8
Elements




           9
Elements
UIATarget.localTarget()




                          9
Elements
UIATarget.localTarget()
  frontMostApp()




                          9
Elements
UIATarget.localTarget()
  frontMostApp()
    mainWindow()




                          10
Elements
UIATarget.localTarget()
  frontMostApp()
    mainWindow()
      tableViews()[0]




                          11
Elements
UIATarget.localTarget()
  frontMostApp()
    mainWindow()
      tableViews()[0]
         cells()[5]




                          12
Elements
UIATarget.localTarget()
  frontMostApp()
    mainWindow()
      tableViews()[0]
         cells()[5]
           elements()[“Name”]



                                13
You are where?




                 14
You are where?


UIATarget.localTarget().logElementTree()




                                           14
You are where?


UIATarget.localTarget().logElementTree()
  The UIAutomation equivalent of Google Maps




                                               14
Demo


logElementTree()

                   15
16
UIATarget.localTarget()




                          17
UIATarget.localTarget().frontMostApp()




                                         18
UIATarget.localTarget().frontMostApp().mainWindow()




                                                      19
UIATarget.localTarget().frontMostApp().mainWindow().navig
ationBar()



                                                            20
UIATarget.localTarget().frontMostApp().mainWindow().navig
ationBar().buttons()



                                                            21
UIATarget.localTarget().frontMostApp().mainWindow().navig
ationBar().buttons()[“Send”]



                                                            22
Interactions - Taps




                      23
Interactions - Taps

 element.tap()




                      23
Interactions - Taps

 element.tap()
 element.tapWithOptions()




                            23
Interactions - Taps

 element.tap()
 element.tapWithOptions()
   number of taps




                            23
Interactions - Taps

 element.tap()
 element.tapWithOptions()
   number of taps
   number of fingers




                            23
Interactions - Taps

 element.tap()
 element.tapWithOptions()
   number of taps
   number of fingers
   length of tap




                            23
Interactions - Taps

 element.tap()
 element.tapWithOptions()
   number of taps
   number of fingers
   length of tap
   offset of tap


                            23
Interactions - More taps




                           24
Interactions - More taps


 touchAndHold()




                           24
Interactions - More taps


 touchAndHold()
 doubleTap()




                           24
Interactions - More taps


 touchAndHold()
 doubleTap()
 twoFingerTap()




                           24
Interactions - Others




                        25
Interactions - Others


 dragInsideWithOptions()




                           25
Interactions - Others


 dragInsideWithOptions()
 flickInsideWithOptions()




                            25
Interactions - Others


 dragInsideWithOptions()
 flickInsideWithOptions()
 scrollToVisible()




                            25
Screenshots




              26
Screenshots


captureScreenWithName()




                          26
Screenshots


captureScreenWithName()
 Does what it says




                          26
Screenshots


captureScreenWithName()
 Does what it says
 Doesn’t work with the simulator (currently)




                                               26
Screenshots


captureScreenWithName()
 Does what it says
 Doesn’t work with the simulator (currently)
 I usually include them with a failed assert




                                               26
Output

Instruments will output a .plist file with the log
XSL to make a nice looking report
  http://blog.essencework.com/post/1728269540/xcode-uiautomation-for-test-
  result-report-part-2

Add the xsl processing to the .plist xml
  <?xml-stylesheet href="Formatter.xsl" type="text/xsl"?>

Open in a browser


                                                                             27
Conclusion




             28
Conclusion


UIAutomation is another tool to ensure robust software




                                                         28
Conclusion


UIAutomation is another tool to ensure robust software
It takes the pain away from routine UI testing




                                                         28
Conclusion


UIAutomation is another tool to ensure robust software
It takes the pain away from routine UI testing
Gets you started on adding accessibility to apps




                                                         28
Conclusion


UIAutomation is another tool to ensure robust software
It takes the pain away from routine UI testing
Gets you started on adding accessibility to apps
A good way to do demos and videos




                                                         28
Resources




            29
Resources

WWDC 2010 Videos - Session 306




                                 29
Resources

WWDC 2010 Videos - Session 306
UI Automation Reference Collection




                                     29
Resources

WWDC 2010 Videos - Session 306
UI Automation Reference Collection
  http://developer.apple.com/library/ios/#documentation/DeveloperTools/
  Reference/UIAutomationRef/Introduction/Introduction.html




                                                                          29
Resources

WWDC 2010 Videos - Session 306
UI Automation Reference Collection
  http://developer.apple.com/library/ios/#documentation/DeveloperTools/
  Reference/UIAutomationRef/Introduction/Introduction.html

Alex Vollmer’s blog (3 July 2010)




                                                                          29
Resources

WWDC 2010 Videos - Session 306
UI Automation Reference Collection
  http://developer.apple.com/library/ios/#documentation/DeveloperTools/
  Reference/UIAutomationRef/Introduction/Introduction.html

Alex Vollmer’s blog (3 July 2010)
  http://alexvollmer.com/posts/2010/07/03/working-with-uiautomation/




                                                                          29
Resources

WWDC 2010 Videos - Session 306
UI Automation Reference Collection
  http://developer.apple.com/library/ios/#documentation/DeveloperTools/
  Reference/UIAutomationRef/Introduction/Introduction.html

Alex Vollmer’s blog (3 July 2010)
  http://alexvollmer.com/posts/2010/07/03/working-with-uiautomation/

dcr@afiyf.com.au, @reidyd


                                                                          29

More Related Content

PDF
[XCode] Automating UI Testing
PPT
Automating UI testing
PDF
Unit testing basic
ODP
Easymock Tutorial
PPTX
Unit Testing in Java
PDF
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
PPT
JMockit Framework Overview
PPTX
Secret unit testing tools no one ever told you about
[XCode] Automating UI Testing
Automating UI testing
Unit testing basic
Easymock Tutorial
Unit Testing in Java
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JMockit Framework Overview
Secret unit testing tools no one ever told you about

What's hot (20)

PPTX
Frontend training
PPTX
PDF
Crash Wars - The handling awakens
PDF
Functional Testing for React Native Apps
PPTX
Java programming-Event Handling
PPTX
Easy mock
PPTX
Junit, mockito, etc
PPTX
Mocking with Mockito
PDF
2011 py con
PPT
JsUnit
PPTX
Mock with Mockito
PPTX
Power mock
PDF
Gett - Mobile automation 2015
PDF
2013 DevFest Vienna - Bad Tests, Good Tests
PDF
otp_authentication_django
PDF
All about unit testing using (power) mock
PDF
081107 Sammy Eclipse Summit2
PDF
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
PPTX
Grails Spock Testing
PPTX
Enterprise js pratices
Frontend training
Crash Wars - The handling awakens
Functional Testing for React Native Apps
Java programming-Event Handling
Easy mock
Junit, mockito, etc
Mocking with Mockito
2011 py con
JsUnit
Mock with Mockito
Power mock
Gett - Mobile automation 2015
2013 DevFest Vienna - Bad Tests, Good Tests
otp_authentication_django
All about unit testing using (power) mock
081107 Sammy Eclipse Summit2
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Grails Spock Testing
Enterprise js pratices
Ad

Similar to Automated ui testing (20)

KEY
Effectively Using UI Automation
PPTX
iOS Human Interface Guidelines (HCI)
PDF
iOS Human Interface Guidlines for iOS-Platforms
PDF
HCI Guidelines for iOS Platforms
KEY
Introduction to Mobile-UI Automated Testing Tools
KEY
UIAutomation + Mechanic.js
PDF
UI (User Interface Testing) - A Complete Guide.pdf
PPT
Mobile Apps Testing - Part 2
PDF
How to: Accessible iPhone/iPad apps that the blind can use with Rubymotion
PDF
Ruby motion and-ios-accessibility
PPT
Programming iOS in C#
PDF
Uxperts mobi 2013 ux for i os
PDF
Cucumber meets iPhone
PDF
Mobile hig
PPT
Using Selenium to Test Native Apps (Wait, you can do that?)
PDF
Introduction to UI Automation Framework
KEY
Ui BDD Testing
PDF
iOS humaninterfaceguidelines
PPT
Natural User Interfases (NUIs) - Android TO Conference 2012
PDF
Mobile Human interface giude
Effectively Using UI Automation
iOS Human Interface Guidelines (HCI)
iOS Human Interface Guidlines for iOS-Platforms
HCI Guidelines for iOS Platforms
Introduction to Mobile-UI Automated Testing Tools
UIAutomation + Mechanic.js
UI (User Interface Testing) - A Complete Guide.pdf
Mobile Apps Testing - Part 2
How to: Accessible iPhone/iPad apps that the blind can use with Rubymotion
Ruby motion and-ios-accessibility
Programming iOS in C#
Uxperts mobi 2013 ux for i os
Cucumber meets iPhone
Mobile hig
Using Selenium to Test Native Apps (Wait, you can do that?)
Introduction to UI Automation Framework
Ui BDD Testing
iOS humaninterfaceguidelines
Natural User Interfases (NUIs) - Android TO Conference 2012
Mobile Human interface giude
Ad

Automated ui testing

Editor's Notes