Four Tips for More Testable UI

Four Tips for More Testable UI

Quick talk given at the 2019 Microsoft MVP summit during the ALM group's MVP2MVP sessions.

Fd80f9c58b06270d42356dd77a32defa?s=128

Jim Holmes

March 17, 2019
Tweet

Transcript

  1. Testable UIs

  2. Or: How to help your test automation folks drink less

  3. jim@GuidepostSystems.com @aJimHolmes

  4. Fortune 10 client Java 6 Enterprise-ready components HP build and

    SCM tools “What’s a unit test?”
  5. Thank you ET

  6. Generalized Talk Ideas apply to all UI and automation tools

  7. https://github.com/jimholmes/ Demo-Site

  8. Two main problems in all UI testing

  9. Finding Stuff

  10. Async

  11. Also SharePoint

  12. Finding stuff == Locators

  13. For Web, prefer: IDs CSS/JQuery-ish Name Custom Attributes

  14. As a last resort: XPath

  15. None
  16. Create Good Locators

  17. 0) Own Your HTML

  18. None
  19. None
  20. None
  21. FindElement.ById(“grid”)

  22. None
  23. None
  24. 1) Understand your controls / frameworks

  25. None
  26. None
  27. None
  28. FindElement.ByCss( “some big stupid CSS string”)

  29. Someone changes style

  30. None
  31. None
  32. None
  33. FindElement.ById( “update-btn”)

  34. 2) Tweak dynamic data

  35. None
  36. Find elements by text content. Might not be granular enough.

  37. None
  38. None
  39. No useful attributes

  40. None
  41. None
  42. None
  43. ID is position-based. Data changes, IDs change.

  44. None
  45. We own the code!

  46. Is there some useful data in your objects?

  47. None
  48. None
  49. None
  50. None
  51. None
  52. FindElement.ById( contains(“Cobb”) )

  53. “Name” isn’t all that useful. Got contract numbers? Project IDs?

    Other stuff? Find good metadata!
  54. 3) Make complex async less painful

  55. None
  56. SharePoint

  57. wait until expected condition 1 wait until expected condition 2

    IF SOMETHING wait until expected condition 3 IF SOMETHING ELSE wait until expected condition 4 FINALLY wait until expected condition 342
  58. We own the code!

  59. Create “flags” when async is complete

  60. None
  61. None
  62. None
  63. None
  64. None
  65. Wait until flags.div(responseType=create) exists

  66. 0) Add static IDs 1) Tweak controls 2) Use data

    for locators 3) Build flags/latches for complex async
  67. None
  68. https://github.com/jimholmes/ Demo-Site