SlideShare une entreprise Scribd logo
1  sur  27
Today I’d like to talk about UIAutomation,
          how you can use it to make your iOS apps
          better.

          After I’ve given you the downlow on UIA,
          I’m going to show you how to make it
          better with a framework I’ve created called
          mechanic.




mechanic.js
uiautomation++
So what is UIAutomation? UIAutomation is a
         software tool (and its accompanying
         framework) built by Apple that allows
         developers to automate interacting with their
         iOS apps for testing.

         UIAutomation makes it easy to script clicks,
         drags, location changes, etc. and allows you
         to assert on the state of your UI.




what is
uiautomation?
play time:
1. Open your favorite project in XCode
2. Cmd-I
3. Choose “Automation” as the Trace Template and click
  “Profile”
4. In the “Scripts” section, click “Add” and create a
  script
5. Automate!
                            4) You don’t have to create a new script, you can import an
                            existing script in your source directory.

                            - Scripts can be ran from the console using the ‘instruments’
                            cmd line utility, as well.

                            - The ‘bwoken’ gem can also be used - it allows you to write
                            tests in coffeescript and run them from the cmd line (though I
                            haven’t been able to get it to work for me just yet)

                            * open instruments and create a simple script that logs element
                            tree for frontMostApp().mainWindow() and describe it *
* show uiautomation/jasmine demo. Explain how it is set
           up (i.e. how to use #import, etc.) *

           * for those of you not familiar with jasmine, it’s an
           RSpec-like framework for writing Javascript specs




uiautomation and
jasmine are pretty cool..
UIAutomation is not without it’s blemishes. Though it’s Apple’s official tool for this
              sort of automation (one reason I’d be wary of using tools like Square’s KIF and
              Frankified), it’s very young

              1. The API isn’t shaped like a modern JS framework like we expect (underscore,
              jQuery, requireJS, Knockout, etc.)

              2. The API is relatively verbose (and at times redundant)

              3. The mechanisms to navigate your app’s “DOM” make it difficult to “get” the
              elements you’re trying to interact with and assert on




what’s the catch?
    What’s the answer to these problems? Mechanic is (or I hope it is)!

    Mechanic servers as a shim to alleviate these pains.
So...


        What’s in
          it for me?
So I’ve given you the elevator pitch.. Now the hard sell:




actions speak louder
than words...
var mainWindow =
UIATarget.localTarget().frontMostApp.mainWindow();
mainWindow.tableViews[‘members’].cells()[‘First row’].tap();
UIATarget.localTarget().delay(2);
var navBar = mainWindow.navigationBars()[‘userDetails’];

assertEquals(‘Back’, navBar.buttons()[0].label());
assertEquals(‘Close’, navBar.buttons()[1].label());


                                 vs                   (describe what the code is
$(‘#members cell’).first()                             doing)
                                                      * # of lines is not much
 .tap()                                               different buuuutttt...
                                                      * code density
 .delay(2);                                           * law of demeter
                                                      * cheated a bit, top code
                                                      would span more lines if
var buttons = $(‘#userDetails button’);               abstracted to the same level

assertEquals(‘Back’, buttons[0].label());
assertEquals(‘Close’, buttons[0].last().label());
and another...
// click all buttons
 var mainWindow = UIATarget.localTarget().frontMostApp.mainWindow();
 var i, j, k, l, m, n, o, p;
 var someButtonElements = mainWindow.elements[‘some_buttons’].elements();
 for (i = 0; i < someButtonElements.length; i++) {
    if (someButtonElements typeof UIAButton) {
      someButtonElements[i].tap();
    }
 }
 var moreButtons = mainWindow.scrollViews()[‘first scrollview’].elements();
 for (i = 0; i < moreButtons.length; i++) {
    if (moreButtons typeof UIAButton) {
      moreButtons[i].tap();
    }



                                         vs
 }
 // ...snip




                                                       (describe what the code is doing - trying to tap all
                                                       of the buttons in the app’s window)

                                                       * the non-mechanic version is intrinsically more
$(‘button’).tap();                                     difficult since there’s no easy mechanism for
                                                       searching the window’s “DOM”
                                                       * This example might be unfair - is it a realistic use
                                                       case?
* mechanic-core is the heart of
                mechanic
                * it’s the reason I wrote / am writing
                mechanic
                * gives you the DOM searching/
                traversing that’s missing from
                UIAutomation, similar to jQuery,
                Prototype, etc.
                * gives you the chaining that we
                know and love and have come to
                expect in selector engines.
                * The other “modules” in mechanic
                are really just niceties or chained
                wrappers on top of the existing
                  UIAutomation APIs.




act i.
mechanic-core
selector                         * UIAutomation places different element
                                     types (buttons, text, images, table cells,



    shortcuts
                                     etc.) into rather verbose classes. When
                                     searching for elements of a certain type,
                                     I’ve provided shorter class names to
                                     decrease the signal-to-noise ratio.




The UIAutomation environment is
pretty minimal. Mechanic provides
                                    functional
                                    extensions
some simple functional-type
functions like map, each, slice,
reduce, etc.




      dom
                                            Most of the UIAutomation scripting
                                            I’ve done, most of the work goes
                                            into “getting” the element you’re



      traversal
                                            looking for. Mechanic provides a
                                            number of means of filtering and
                                            expanding sets of matched
                                            elements.
find stuff:
           (+ more)

$(‘#my-scroll-view image’).each(function(img) { img.log(); });


$(‘text’, aPopover).siblings(‘image’);


var names = $(‘*’).map(function() { return this.name() });


var allNonTextEls = $(‘window’).children().not(‘text’);


var el = $(‘*’).predicate(‘where label == “Some label”’);
act ii.
events
device
                                            We can change the device’s volume,
                                            location, lock the device, etc.




manipulation

Simulate screen touches, rotations, etc.
                                           screen
                                           actions

element
                                              taps, touches, rotations on
                                              buttons, pickers, text, etc.




interaction
do stuff:
             (+ more)


$.orientation(UIA_DEVICE_ORIENTATION_LANDSCAPELEFT);

$.volume(‘down’, 2);

$(‘#my-scrollview’).dragInside(
 {startOffset : {x:0,y:2}, endOffset: {x:20,y:30}, duration:2});


$(‘#password’, loginScreen).input(‘my password’);


$(‘#my-scroll-view text’).last().scrollToVisible();
act iii.
data
application
preferences

         element
         details
  app
  info
get stuff:
            (+ more)

$.message($(aStaticTextElement).value());


var firstImageLabel = $(‘image’).first().label();


$.message($.bundleId());


$.prefs({ prefA: 1, prefB: ‘some value’ });


var lastElIsVisible = $(‘*’).last().isVisible();
act iv.
logging
screen
  capture
            console
            logging
element
information
record stuff:
        (+ more.. well, not really..)

$.warn(‘An element was not where it should have been!’);


$(‘text’).log();


$(‘window’).logTree();


$(‘image’).capture();

$(‘#my-button’).tap()
 .parent().capture()
 .message(‘tapped the button and then captured a picture!’);
act v.
act v.
choose your
own adventure!
selectors
    documentation
                         more coverage
                                               assertions??
Big thing is that only simple selectors are
                                                create issues
supported, though the functions in mechanic-        use it!!!
core make it easy to construct complex               please...?
constructors.

Reworking mechanic-core based on Sizzle
and qwery currently, which should expose
more complex queries.
submit issues. read docs. fork. download. commit. write specs. add
new features. maintain examples. submit issues. read docs. fork.
download. commit. write specs. add new features. maintain
examples. submit issues. read docs. fork. download. commit. write
specs. add new features. maintain examples. submit issues. read
docs. fork. download. commit. write specs. add new features.
maintain examples. submit issues. read docs. fork. download.
commit. write specs. add new features. maintain examples. submit
issues. read docs. fork. download. commit. write specs. add new
features. maintain examples. submit issues. read docs. fork.
download. commit. write specs. add new features. maintain
                                    find out more @
examples.submit issues. read docs. fork. download. commit. write
             github.com/jaykz52/mechanic
specs. add new features. maintain examples. submit issues. read
docs. fork. download. commit. write specs. add new features.
maintain examples. submit issues. read docs. fork. download.
commit. write specs. add new features. maintain examples. submit
issues. read docs. fork. download. commit. write specs. submit
QUESTIONS???

@jaykz52
I L OV E TO TA L K

Contenu connexe

Tendances

Learning Appcelerator® Alloy™
Learning Appcelerator® Alloy™Learning Appcelerator® Alloy™
Learning Appcelerator® Alloy™Ricardo Alcocer
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorialsumitjoshi01
 
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...彼得潘 Pan
 
The City Bars App with Sencha Touch 2
The City Bars App with Sencha Touch 2The City Bars App with Sencha Touch 2
The City Bars App with Sencha Touch 2James Pearce
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App DevelopmentKetan Raval
 
JWC - Rapid application development with FOF
JWC - Rapid application development with FOFJWC - Rapid application development with FOF
JWC - Rapid application development with FOFNicholas Dionysopoulos
 
Sencha Touch - Introduction
Sencha Touch - IntroductionSencha Touch - Introduction
Sencha Touch - IntroductionABC-GROEP.BE
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoRob Bontekoe
 
Beginning iphone 4_devlopement_chpter7_tab_b
Beginning iphone 4_devlopement_chpter7_tab_bBeginning iphone 4_devlopement_chpter7_tab_b
Beginning iphone 4_devlopement_chpter7_tab_bJihoon Kong
 
Rich mobile apps with sencha touch - class system
Rich mobile apps with sencha touch  -  class systemRich mobile apps with sencha touch  -  class system
Rich mobile apps with sencha touch - class systemncosmin2001
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoMohamed Mosaad
 
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comDrupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comJD Leonard
 

Tendances (13)

Learning Appcelerator® Alloy™
Learning Appcelerator® Alloy™Learning Appcelerator® Alloy™
Learning Appcelerator® Alloy™
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
 
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
 
Eclipse Tricks
Eclipse TricksEclipse Tricks
Eclipse Tricks
 
The City Bars App with Sencha Touch 2
The City Bars App with Sencha Touch 2The City Bars App with Sencha Touch 2
The City Bars App with Sencha Touch 2
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App Development
 
JWC - Rapid application development with FOF
JWC - Rapid application development with FOFJWC - Rapid application development with FOF
JWC - Rapid application development with FOF
 
Sencha Touch - Introduction
Sencha Touch - IntroductionSencha Touch - Introduction
Sencha Touch - Introduction
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
Beginning iphone 4_devlopement_chpter7_tab_b
Beginning iphone 4_devlopement_chpter7_tab_bBeginning iphone 4_devlopement_chpter7_tab_b
Beginning iphone 4_devlopement_chpter7_tab_b
 
Rich mobile apps with sencha touch - class system
Rich mobile apps with sencha touch  -  class systemRich mobile apps with sencha touch  -  class system
Rich mobile apps with sencha touch - class system
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup Cairo
 
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comDrupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.com
 

En vedette

45 Tools to Boost Your Front-End
45 Tools to Boost Your Front-End45 Tools to Boost Your Front-End
45 Tools to Boost Your Front-EndNicolas PENNEC
 
The Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsThe Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsSauce Labs
 
WebDriver: The Final Frontier - Selenium Camp 2014
WebDriver: The Final Frontier - Selenium Camp 2014WebDriver: The Final Frontier - Selenium Camp 2014
WebDriver: The Final Frontier - Selenium Camp 2014Sauce Labs
 
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...Badoo
 
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...Badoo
 
Testing Metrics - Making your tests visible
Testing Metrics - Making your tests visibleTesting Metrics - Making your tests visible
Testing Metrics - Making your tests visibleAlper Mermer
 
An easy way to automate complex UI
An easy way to automate complex UIAn easy way to automate complex UI
An easy way to automate complex UIIvan Pashko
 
Test Automation Architecture in Microservices
Test Automation Architecture in MicroservicesTest Automation Architecture in Microservices
Test Automation Architecture in MicroservicesAlper Mermer
 
End-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical ScaleEnd-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical ScaleErdem YILDIRIM
 

En vedette (9)

45 Tools to Boost Your Front-End
45 Tools to Boost Your Front-End45 Tools to Boost Your Front-End
45 Tools to Boost Your Front-End
 
The Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsThe Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native Apps
 
WebDriver: The Final Frontier - Selenium Camp 2014
WebDriver: The Final Frontier - Selenium Camp 2014WebDriver: The Final Frontier - Selenium Camp 2014
WebDriver: The Final Frontier - Selenium Camp 2014
 
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...
 
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
 
Testing Metrics - Making your tests visible
Testing Metrics - Making your tests visibleTesting Metrics - Making your tests visible
Testing Metrics - Making your tests visible
 
An easy way to automate complex UI
An easy way to automate complex UIAn easy way to automate complex UI
An easy way to automate complex UI
 
Test Automation Architecture in Microservices
Test Automation Architecture in MicroservicesTest Automation Architecture in Microservices
Test Automation Architecture in Microservices
 
End-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical ScaleEnd-to-End Test Automation for Both Horizontal and Vertical Scale
End-to-End Test Automation for Both Horizontal and Vertical Scale
 

Similaire à UIAutomation + Mechanic.js

iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation PrimitivesSynack
 
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Mikhail Sosonkin
 
Introduction to nodejs
Introduction to nodejsIntroduction to nodejs
Introduction to nodejsJames Carr
 
UI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksUI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksTsimafei Avilin
 
Top 3 SWT Exceptions
Top 3 SWT ExceptionsTop 3 SWT Exceptions
Top 3 SWT ExceptionsLakshmi Priya
 
Implementation
ImplementationImplementation
Implementationhcicourse
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhoneErin Dees
 
[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...Functional Thursday
 
Cocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOSCocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOSIdean France
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup PerformanceJustin Cataldo
 
A to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperA to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperManoj Bhuva
 
The Mouse is mightier than the sword
The Mouse is mightier than the swordThe Mouse is mightier than the sword
The Mouse is mightier than the swordPriyanka Aash
 
Story about module management with angular.js
Story about module management with angular.jsStory about module management with angular.js
Story about module management with angular.jsDavid Amend
 
Migrating Objective-C to Swift
Migrating Objective-C to SwiftMigrating Objective-C to Swift
Migrating Objective-C to SwiftElmar Kretzer
 

Similaire à UIAutomation + Mechanic.js (20)

iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation Primitives
 
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016
 
Introduction to nodejs
Introduction to nodejsIntroduction to nodejs
Introduction to nodejs
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
 
UI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksUI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricks
 
Top 3 SWT Exceptions
Top 3 SWT ExceptionsTop 3 SWT Exceptions
Top 3 SWT Exceptions
 
Implementation
ImplementationImplementation
Implementation
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
iOS
iOSiOS
iOS
 
[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...
 
Clipboard support on Y! mail
Clipboard support on Y! mailClipboard support on Y! mail
Clipboard support on Y! mail
 
Cocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOSCocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOS
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
Mobile optimization
Mobile optimizationMobile optimization
Mobile optimization
 
A to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperA to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java Developer
 
The Mouse is mightier than the sword
The Mouse is mightier than the swordThe Mouse is mightier than the sword
The Mouse is mightier than the sword
 
Story about module management with angular.js
Story about module management with angular.jsStory about module management with angular.js
Story about module management with angular.js
 
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)
 
Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
 
Migrating Objective-C to Swift
Migrating Objective-C to SwiftMigrating Objective-C to Swift
Migrating Objective-C to Swift
 

Dernier

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Dernier (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

UIAutomation + Mechanic.js

  • 1. Today I’d like to talk about UIAutomation, how you can use it to make your iOS apps better. After I’ve given you the downlow on UIA, I’m going to show you how to make it better with a framework I’ve created called mechanic. mechanic.js uiautomation++
  • 2. So what is UIAutomation? UIAutomation is a software tool (and its accompanying framework) built by Apple that allows developers to automate interacting with their iOS apps for testing. UIAutomation makes it easy to script clicks, drags, location changes, etc. and allows you to assert on the state of your UI. what is uiautomation?
  • 3. play time: 1. Open your favorite project in XCode 2. Cmd-I 3. Choose “Automation” as the Trace Template and click “Profile” 4. In the “Scripts” section, click “Add” and create a script 5. Automate! 4) You don’t have to create a new script, you can import an existing script in your source directory. - Scripts can be ran from the console using the ‘instruments’ cmd line utility, as well. - The ‘bwoken’ gem can also be used - it allows you to write tests in coffeescript and run them from the cmd line (though I haven’t been able to get it to work for me just yet) * open instruments and create a simple script that logs element tree for frontMostApp().mainWindow() and describe it *
  • 4. * show uiautomation/jasmine demo. Explain how it is set up (i.e. how to use #import, etc.) * * for those of you not familiar with jasmine, it’s an RSpec-like framework for writing Javascript specs uiautomation and jasmine are pretty cool..
  • 5. UIAutomation is not without it’s blemishes. Though it’s Apple’s official tool for this sort of automation (one reason I’d be wary of using tools like Square’s KIF and Frankified), it’s very young 1. The API isn’t shaped like a modern JS framework like we expect (underscore, jQuery, requireJS, Knockout, etc.) 2. The API is relatively verbose (and at times redundant) 3. The mechanisms to navigate your app’s “DOM” make it difficult to “get” the elements you’re trying to interact with and assert on what’s the catch? What’s the answer to these problems? Mechanic is (or I hope it is)! Mechanic servers as a shim to alleviate these pains.
  • 6. So... What’s in it for me?
  • 7. So I’ve given you the elevator pitch.. Now the hard sell: actions speak louder than words...
  • 8. var mainWindow = UIATarget.localTarget().frontMostApp.mainWindow(); mainWindow.tableViews[‘members’].cells()[‘First row’].tap(); UIATarget.localTarget().delay(2); var navBar = mainWindow.navigationBars()[‘userDetails’]; assertEquals(‘Back’, navBar.buttons()[0].label()); assertEquals(‘Close’, navBar.buttons()[1].label()); vs (describe what the code is $(‘#members cell’).first() doing) * # of lines is not much .tap() different buuuutttt... * code density .delay(2); * law of demeter * cheated a bit, top code would span more lines if var buttons = $(‘#userDetails button’); abstracted to the same level assertEquals(‘Back’, buttons[0].label()); assertEquals(‘Close’, buttons[0].last().label());
  • 10. // click all buttons var mainWindow = UIATarget.localTarget().frontMostApp.mainWindow(); var i, j, k, l, m, n, o, p; var someButtonElements = mainWindow.elements[‘some_buttons’].elements(); for (i = 0; i < someButtonElements.length; i++) { if (someButtonElements typeof UIAButton) { someButtonElements[i].tap(); } } var moreButtons = mainWindow.scrollViews()[‘first scrollview’].elements(); for (i = 0; i < moreButtons.length; i++) { if (moreButtons typeof UIAButton) { moreButtons[i].tap(); } vs } // ...snip (describe what the code is doing - trying to tap all of the buttons in the app’s window) * the non-mechanic version is intrinsically more $(‘button’).tap(); difficult since there’s no easy mechanism for searching the window’s “DOM” * This example might be unfair - is it a realistic use case?
  • 11. * mechanic-core is the heart of mechanic * it’s the reason I wrote / am writing mechanic * gives you the DOM searching/ traversing that’s missing from UIAutomation, similar to jQuery, Prototype, etc. * gives you the chaining that we know and love and have come to expect in selector engines. * The other “modules” in mechanic are really just niceties or chained wrappers on top of the existing UIAutomation APIs. act i. mechanic-core
  • 12. selector * UIAutomation places different element types (buttons, text, images, table cells, shortcuts etc.) into rather verbose classes. When searching for elements of a certain type, I’ve provided shorter class names to decrease the signal-to-noise ratio. The UIAutomation environment is pretty minimal. Mechanic provides functional extensions some simple functional-type functions like map, each, slice, reduce, etc. dom Most of the UIAutomation scripting I’ve done, most of the work goes into “getting” the element you’re traversal looking for. Mechanic provides a number of means of filtering and expanding sets of matched elements.
  • 13. find stuff: (+ more) $(‘#my-scroll-view image’).each(function(img) { img.log(); }); $(‘text’, aPopover).siblings(‘image’); var names = $(‘*’).map(function() { return this.name() }); var allNonTextEls = $(‘window’).children().not(‘text’); var el = $(‘*’).predicate(‘where label == “Some label”’);
  • 15. device We can change the device’s volume, location, lock the device, etc. manipulation Simulate screen touches, rotations, etc. screen actions element taps, touches, rotations on buttons, pickers, text, etc. interaction
  • 16. do stuff: (+ more) $.orientation(UIA_DEVICE_ORIENTATION_LANDSCAPELEFT); $.volume(‘down’, 2); $(‘#my-scrollview’).dragInside( {startOffset : {x:0,y:2}, endOffset: {x:20,y:30}, duration:2}); $(‘#password’, loginScreen).input(‘my password’); $(‘#my-scroll-view text’).last().scrollToVisible();
  • 18. application preferences element details app info
  • 19. get stuff: (+ more) $.message($(aStaticTextElement).value()); var firstImageLabel = $(‘image’).first().label(); $.message($.bundleId()); $.prefs({ prefA: 1, prefB: ‘some value’ }); var lastElIsVisible = $(‘*’).last().isVisible();
  • 21. screen capture console logging element information
  • 22. record stuff: (+ more.. well, not really..) $.warn(‘An element was not where it should have been!’); $(‘text’).log(); $(‘window’).logTree(); $(‘image’).capture(); $(‘#my-button’).tap() .parent().capture() .message(‘tapped the button and then captured a picture!’);
  • 25. selectors documentation more coverage assertions?? Big thing is that only simple selectors are create issues supported, though the functions in mechanic- use it!!! core make it easy to construct complex please...? constructors. Reworking mechanic-core based on Sizzle and qwery currently, which should expose more complex queries.
  • 26. submit issues. read docs. fork. download. commit. write specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. add new features. maintain find out more @ examples.submit issues. read docs. fork. download. commit. write github.com/jaykz52/mechanic specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. add new features. maintain examples. submit issues. read docs. fork. download. commit. write specs. submit

Notes de l'éditeur

  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