SlideShare una empresa de Scribd logo
1 de 83
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

Más contenido relacionado

La actualidad más candente

Crash Wars - The handling awakens
Crash Wars  - The handling awakensCrash Wars  - The handling awakens
Crash Wars - The handling awakensŽeljko Plesac
 
Functional Testing for React Native Apps
Functional Testing for React Native AppsFunctional Testing for React Native Apps
Functional Testing for React Native AppsK. Matthew Dupree
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event HandlingJava Programming
 
Junit, mockito, etc
Junit, mockito, etcJunit, mockito, etc
Junit, mockito, etcYaron Karni
 
2011 py con
2011 py con2011 py con
2011 py conEing Ong
 
Gett - Mobile automation 2015
Gett - Mobile automation 2015Gett - Mobile automation 2015
Gett - Mobile automation 2015adi ben aroya
 
2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good Tests2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good TestsTomek Kaczanowski
 
otp_authentication_django
otp_authentication_djangootp_authentication_django
otp_authentication_djangoGladson Manuel
 
All about unit testing using (power) mock
All about unit testing using (power) mockAll about unit testing using (power) mock
All about unit testing using (power) mockPranalee Rokde
 
081107 Sammy Eclipse Summit2
081107   Sammy   Eclipse Summit2081107   Sammy   Eclipse Summit2
081107 Sammy Eclipse Summit2mkempka
 
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesJava Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesAbdul Rahman Sherzad
 

La actualidad más candente (20)

Frontend training
Frontend trainingFrontend training
Frontend training
 
Mockito
MockitoMockito
Mockito
 
Crash Wars - The handling awakens
Crash Wars  - The handling awakensCrash Wars  - The handling awakens
Crash Wars - The handling awakens
 
Functional Testing for React Native Apps
Functional Testing for React Native AppsFunctional Testing for React Native Apps
Functional Testing for React Native Apps
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
 
Easy mock
Easy mockEasy mock
Easy mock
 
Junit, mockito, etc
Junit, mockito, etcJunit, mockito, etc
Junit, mockito, etc
 
Mocking with Mockito
Mocking with MockitoMocking with Mockito
Mocking with Mockito
 
2011 py con
2011 py con2011 py con
2011 py con
 
JsUnit
JsUnitJsUnit
JsUnit
 
Mock with Mockito
Mock with MockitoMock with Mockito
Mock with Mockito
 
Power mock
Power mockPower mock
Power mock
 
Gett - Mobile automation 2015
Gett - Mobile automation 2015Gett - Mobile automation 2015
Gett - Mobile automation 2015
 
2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good Tests2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good Tests
 
otp_authentication_django
otp_authentication_djangootp_authentication_django
otp_authentication_django
 
All about unit testing using (power) mock
All about unit testing using (power) mockAll about unit testing using (power) mock
All about unit testing using (power) mock
 
081107 Sammy Eclipse Summit2
081107   Sammy   Eclipse Summit2081107   Sammy   Eclipse Summit2
081107 Sammy Eclipse Summit2
 
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesJava Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
 
Grails Spock Testing
Grails Spock TestingGrails Spock Testing
Grails Spock Testing
 
Enterprise js pratices
Enterprise js praticesEnterprise js pratices
Enterprise js pratices
 

Similar a Automated UI Testing Guide for Confident User Experiences

Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhoneErin Dees
 
XCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with XcodeXCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with XcodepCloudy
 
Hidden Object Detection for Computer Vision Based Test Automation System
Hidden Object Detection for Computer Vision Based Test Automation SystemHidden Object Detection for Computer Vision Based Test Automation System
Hidden Object Detection for Computer Vision Based Test Automation SystemSyeful Islam
 
The fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactThe fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactOliver N
 
Asynchronous Programming in Android
Asynchronous Programming in AndroidAsynchronous Programming in Android
Asynchronous Programming in AndroidJohn Pendexter
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorialsumitjoshi01
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.pptTabassumMaktum
 
"Universal programming recipes", Kateryna Trofimenko
"Universal programming recipes", Kateryna Trofimenko"Universal programming recipes", Kateryna Trofimenko
"Universal programming recipes", Kateryna TrofimenkoBadoo Development
 
Universal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Universal programming recipes​ - Ekaterina Trofimenko - Women In TechnologyUniversal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Universal programming recipes​ - Ekaterina Trofimenko - Women In TechnologyBadoo
 
Advance UIAutomator : Documentaion
Advance UIAutomator : DocumentaionAdvance UIAutomator : Documentaion
Advance UIAutomator : DocumentaionRaman Gowda Hullur
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espressoÉdipo Souza
 

Similar a Automated UI Testing Guide for Confident User Experiences (20)

UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
Swift
SwiftSwift
Swift
 
iOS UI Automation
iOS UI AutomationiOS UI Automation
iOS UI Automation
 
XCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with XcodeXCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with Xcode
 
Hidden Object Detection for Computer Vision Based Test Automation System
Hidden Object Detection for Computer Vision Based Test Automation SystemHidden Object Detection for Computer Vision Based Test Automation System
Hidden Object Detection for Computer Vision Based Test Automation System
 
The fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactThe fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose React
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
cpuk10745
cpuk10745cpuk10745
cpuk10745
 
Asynchronous Programming in Android
Asynchronous Programming in AndroidAsynchronous Programming in Android
Asynchronous Programming in Android
 
Java-Events
Java-EventsJava-Events
Java-Events
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
 
The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
 
GUI_part_1.pptx
GUI_part_1.pptxGUI_part_1.pptx
GUI_part_1.pptx
 
"Universal programming recipes", Kateryna Trofimenko
"Universal programming recipes", Kateryna Trofimenko"Universal programming recipes", Kateryna Trofimenko
"Universal programming recipes", Kateryna Trofimenko
 
Universal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Universal programming recipes​ - Ekaterina Trofimenko - Women In TechnologyUniversal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Universal programming recipes​ - Ekaterina Trofimenko - Women In Technology
 
Advance UIAutomator : Documentaion
Advance UIAutomator : DocumentaionAdvance UIAutomator : Documentaion
Advance UIAutomator : Documentaion
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espresso
 

Automated UI Testing Guide for Confident User Experiences

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n