Generating Accessibility Identifiers Easily and Consistently Using Reflection API

Generating Accessibility Identifiers Easily and Consistently Using Reflection API

UI TestではAccessibility Identifierを利用して、View 要素の特定をします。
このAccessibility Identifierを簡単に一貫性のある形で設定するための方法を紹介しています。

本文で紹介のコードは以下のGistで公開しています。
https://gist.github.com/ngtk/7d4a92ad506df7f9a36f75f6c63ec835

このトークはPotatotips #61で発表したものです。
https://potatotips.connpass.com/event/127296/

PR:
iOS Nightでは本トークのような内容を毎週火曜日に共有しています。
https://github.com/wantedly/ios_night

88cc995ce5954b15c12ea14904258757?s=128

Kento Nagata

May 15, 2019
Tweet

Transcript

  1. ©2019 Wantedly, Inc. Generating Accessibility Identifiers
 Easily and Consistently
 Using

    Reflection API Potatotips #61 Apr 22, 2019 - Kento Nagata
  2. ©2018 Wantedly, Inc. ,FOUP/BHBUB 8BOUFEMZ *OD4PGUXBSF&OHJOFFS 8IBU*EPOPX ɾ1SPEVDU(SPXUIGPS8BOUFEMZ7JTJU 
 &OHJOFFSJOH

    ɾ3BJMTZFBST ɾJ044XJGUZFBST
  3. ©2019 Wantedly, Inc. 6*5FTUͷͨΊʹ
 "DDFTTJCJMJUZJEFOUJGJFSΛ Ұ؏త͔ͭ؆୯ʹੜ੒͢ΔͨΊํ๏ ࠓ೔࿩͢͜ͱ

  4. ©2019 Wantedly, Inc. 9$5FTUͰ͸ 6*&MFNFOUͷಛఆʹ "DDFTTJCJMJUZ*EFOUJGJFSΛར༻

  5. ©2019 Wantedly, Inc. 6*5FTUͱ"DDFTTJCJMJUZ*EFOUJGJFS

  6. ©2019 Wantedly, Inc. 6*5FTUͱ"DDFTTJCJMJUZ*EFOUJGJFS ϓϩμΫτίʔυͰจࣈྻΛࢦఆ͠

  7. ©2019 Wantedly, Inc. 6*5FTUͱ"DDFTTJCJMJUZ*EFOUJGJFS ςετίʔυͰར༻

  8. ©2019 Wantedly, Inc. "DDFTTJCJMJUZ*EFOUJGJFS͸
 ͲͷΑ͏ͳจࣈྻΛઃఆ͢Δ΂͖͔

  9. ©2019 Wantedly, Inc. 8BOUFEMZ7JTJUJ04
 Ͱͷ࣮૷ํ਑ ΦϑΟεʹؾܰʹ࿩Λฉ͖ʹ͍͚ΔαʔϏε8BOUFEMZ 7JTJUͷJ04ΞϓϦɻ
 ٕज़తഎܠͱͯ͠͸ɺ7JFXͷ΄ͱΜͲ͸ίʔυͰ࣮૷ͯ͠ ͍Δɻ

  10. ©2019 Wantedly, Inc. l$MBTT/BNFQSPQFSUZ/BNFz Ϋϥε໊ͱϓϩύςΟ໊ͷ૊Έ߹Θͤ

  11. ©2019 Wantedly, Inc.  ϓϩύςΟ໊͸ͦͷίϯςΩετʹ͓͍ͯ
 ҙຯ͕ద੾  Ϋϥε໊ΛؚΊΔ͜ͱͰΑΓҰҙʹ w &$6*&MFNFOUͷαϒεΫϦϓτΛར༻Ͱ͖·͢

    αϒεΫϦϓτ͸EFDFOEBOUΛ୳ࡧ͢ΔͨΊɺ
 Ϋϥε໊Λؚ·ͳ͍৔߹ʹ໋໊িಥϦεΫ͕͋Γ·͢  w Ϋϥε໊͕ΞϓϦ֎෦ʹ࿐ग़͍ͯ͠Δ఺ʹ஫ҙ͕ඞཁͰ͢  ϓϩμΫτίʔυΛ୳͠΍͘͢ͳΔ ϝϦοτ
  12. ©2019 Wantedly, Inc.  ͜ͷํ๏͕कΒΕΔ͔͸։ൃऀʹґଘ  ໋໊Λߟ͑ͳͯ͘΋ྑ͍ͱ͸͍͑ɺ
 ຖճॻ͘ͷ͸໘౗ ໰୊఺

  13. ©2019 Wantedly, Inc. Ξϓϩʔν

  14. ©2019 Wantedly, Inc. .JSSPS 4XJGU3FGMFDUJPO"1*

  15. ©2019 Wantedly, Inc. .JSSPSΛར༻ͯ͠ੜ੒

  16. ©2019 Wantedly, Inc. .JSSPSΛར༻ͯ͠ੜ੒ ੜ੒͍ͨ͠viewͷϦϑϨΫγϣϯΛ࡞੒

  17. ©2019 Wantedly, Inc. .JSSPSΛར༻ͯ͠ੜ੒ ͦͷΫϥεͷϓϩύςΟ

  18. ©2019 Wantedly, Inc. .JSSPSΛར༻ͯ͠ੜ੒ ϓϩύςΟͷ஋Λऔಘ

  19. ©2019 Wantedly, Inc. .JSSPSΛར༻ͯ͠ੜ੒ ϓϩύςΟͷ໊લΛऔಘ

  20. ©2019 Wantedly, Inc. .JSSPSΛར༻ͯ͠ੜ੒ “Ϋϥε໊.ϓϩύςΟ໊”Λઃఆ

  21. ©2019 Wantedly, Inc. .JSSPSΛར༻ͯ͠ੜ੒

  22. ©2019 Wantedly, Inc. .JSSPSΛར༻ͯ͠ੜ੒

  23. ©2019 Wantedly, Inc. Ͱ΋ɺ·ͩͩΊ

  24. ©2019 Wantedly, Inc. ਌ΫϥεͰఆٛ͞ΕͨϓϩύςΟΛ
 ѻ͑ͳ͍

  25. ©2019 Wantedly, Inc.  6*7JFX$POUSPMMFSWJFX  6*5BC#BS$POUSPMMFSUBC#BS εʔύʔΫϥεͱͦͷϓϩύςΟྫ

  26. ©2019 Wantedly, Inc. ࠶ؼ

  27. ©2019 Wantedly, Inc. ࠶ؼΛར༻ͯ͠਌Ϋϥε΋ॲཧ

  28. ©2019 Wantedly, Inc. ࠶ؼΛར༻ͯ͠਌Ϋϥε΋ॲཧ ਌ΫϥεͷMirrorΛऔಘͰ͖Δ

  29. ©2019 Wantedly, Inc. Ͱ΋ɺ·ͩͩΊ

  30. ©2019 Wantedly, Inc. PCKDͷఆٛΫϥε͸
 .JSSPSͷ"1*Ͱ͸ݟΕͳ͍

  31. ©2019 Wantedly, Inc. ໨ʹ͸໨Λɺ
 PCKDΫϥεʹ͸PCKDͷϦϑϨΫγϣϯΛ

  32. ©2019 Wantedly, Inc. DMBTT@DPQZ1SPQFSUZ-JTU ΫϥεͷϓϩύςΟϦετΛऔಘ͢Δϝιου

  33. ©2019 Wantedly, Inc. 0CKD3FGMFDUJPOΛར༻࣮ͨ͠૷

  34. ©2019 Wantedly, Inc. 0CKD3FGMFDUJPOΛར༻࣮ͨ͠૷ ϓϩύςΟͷϙΠϯλʔ഑ྻͱͦͷ഑ྻ਺Λऔಘ

  35. ©2019 Wantedly, Inc. 0CKD3FGMFDUJPOΛར༻࣮ͨ͠૷ ϙΠϯλʔ͔Β஋ΛऔΓग़͠ɺϓϩύςΟ໊Λऔಘ

  36. ©2019 Wantedly, Inc. 0CKD3FGMFDUJPOΛར༻࣮ͨ͠૷

  37. ©2019 Wantedly, Inc. ࠷ޙʹɺϓϩτίϧʹ·ͱΊ·͢

  38. ©2019 Wantedly, Inc. 1SPUPDPM"DDFTTJCMF

  39. ©2019 Wantedly, Inc. 1SPUPDPM"DDFTTJCMF w$VTUPN5BC#BS$POUSPMMFSWJFX w$VTUPN5BC#BS$POUSPMMFSUBC#BS w$VTUPN5BC#BS$POUSPMMFSGPP#VUUPO

  40. ©2019 Wantedly, Inc. 1SPUPDPM"DDFTTJCMF https://gist.github.com/ngtk/7d4a92ad506df7f9a36f75f6c63ec835 https://git.io/fjlCs OR Gistʹ׬શͳίʔυ͕͋Γ·͢

  41. ©2019 Wantedly, Inc. ·ͱΊ

  42. ©2019 Wantedly, Inc.  "DDFTTJCJMJUZ*EFOUJpFS͸
 Ϋϥε໊ͱϓϩύςΟ໊ͷ૊Έ߹Θ͕ͤྑ͍  ਌Ϋϥε΁ͷదԠ͸࠶ؼతʹ  3FqFDUJPO"1*Λར༻ͯ͠؆୯ʹҰ؏తʹੜ੒

    w 4XJGUͰ͸.JSSPS w 0CKDͰ͸DMBTT@DPQZ1SPQFSUZ-JTU ·ͱΊ
  43. ©2019 Wantedly, Inc. ຖिՐ༵೔J04/JHIUΛ։࠵͍ͯ͠·͢ IUUQTHJUIVCDPNXBOUFEMZJPT@OJHIU JPT@OJHIU ւ֎ͷϒϩάͳͲ࠷৽ͷ৘ใΛΧδϡΞϧʹڞ༗͋͠͏ձͰ͢ɻ 13