• Home
  • Über mich
  • Impressum

Marc Schlüpmann

My personal View of the World

UI Testing

UIAStepper missing in iOS

18. September 2015 by Marc Schlüpmann Leave a Comment

If you want to automate your user interface for testing or to take screenshots using fastlane you can use Apple’s UI Automation framework. Every element from UIKIt has a corresponding class in UI Automation – every? No, not every element.

The UIStepper class does not has a corresponding UIAStepper class in the testing framework, but it would be nice to automate it, too. If you record your activities on the UI with Instruments you will get something like this:

target.frontMostApp().mainWindow().tableViews()[0].tapWithOptions({tapOffset:{x:0.37, y:0.47}});

If you want to create this not using Instruments it becomes tricky. Even if you try to use the accessibility labels you will fail. By the way: The UIStepper does not has accessibility properties in Interface Builder.

So, what’s the solution?

If you look at the array that is returned by calling elements() on the parent element you will find two UIAButton entries. One with the name „Increment“ and one with the name „Decrement“ – and these two can be used to automate UIStepper actions!

To simulate a tap on the ‚+‘ button on a UIStepper you can simply write:

window.tableViews()[0].cells()[4].elements()["Increment"].tap()

and

window.tableViews()[0].cells()[4].elements()["Decrement"].tap()

to simulate a tap on the ‚-‚ button respectively.

But there is a small snare: The names of the elements are localized! So you have to check for your localization and use the correct strings. For German the strings are ‚Erhöhen‘ and ‚Verringern‘.

It’s that easy, but not documented by Apple. Have fun!

Posted in: iOS Programming Tagged: iOS, Programming, UI Testing, Xcode

What’s hot

Ammersee Denkerhaus Atmen Breitband Bürgerbeteiligung Chart Cordova Coworking currant Diagramm Dießen El Capitan Finanzen Gemeinderat Geschmack Gesundheit Grüne Huber Häuser Internetzugang iOS iOS 6 Jugend Jugendtreff Kommunalwahl MTV Dießen Mühlstraße Nasendusche Netzdiagramm Neues Jahr Obermühlhausen Oenologie OS X Parken Parkplätze Phonegap Politik Programmierung Programming Radar Diagramm Transparenz Untermüllerplatz Videotraining Weihnachten Wein Weinbau Xcode

Kategorien

  • Allgemein
  • Ammersee Denkerhaus
  • Datenschutz
  • Dießen am Ammersee
  • Gemeinderat
  • iOS Programming
  • OS X Programming
  • Podcasts
  • Politik
  • Privat
  • Work

Neueste Kommentare

  • Michael Hofmann bei Bürgerbegehren gestartet
  • Frank Fastl bei Bürgerbegehren gestartet
  • Michael Hofmann bei Bürgerbegehren gestartet
  • Leopold Ploner bei Parken auf dem schönsten Platz von Dießen
  • Leopold Ploner bei Über den Dächern von Dießen

Lesezeichen

  • #Schondorf
  • Ammersee Denkerhaus
  • Ammersee Kurier
  • Annes Art
  • Annes Topfgeflüster
  • Chaos Computer Club
  • Logbuch:Netzpolitik
  • Margarete Bause
  • Obacht! – Reloaded –
  • Petra Sander
  • Renate Standfest
  • Sitzungstermine Dießen

Archive

  • April 2020
  • Februar 2020
  • Januar 2020
  • September 2017
  • Juli 2017
  • Juni 2017
  • Mai 2017
  • März 2017
  • Oktober 2015
  • September 2015
  • Juli 2015
  • April 2015
  • März 2015
  • Januar 2015
  • Oktober 2014
  • Februar 2014
  • Januar 2014
  • Dezember 2013
  • Juni 2013
  • Januar 2013
  • Dezember 2012
  • Mai 2012
  • April 2012
  • März 2012
  • Februar 2012
  • Dezember 2011

Copyright © 2025 Marc Schlüpmann.

Omega WordPress Theme by ThemeHall