9

Using UI tests, I'd like the app to respond to shake gestures, and I would like to programmatically trigger a shake gesture in my swift UI tests.

Triggering the shake gesture while recording during a UI test session yields no added code.

Is there a way to do this? Thanks in advance!

iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
Noah
  • 1,608
  • 15
  • 31
  • It looks like you can... Have you tried this: http://stackoverflow.com/questions/24433763/programmatically-trigger-shake-event-ios ? Specifically the code the question provides and modifying it as suggested by an answer? – Oxcug Jul 25 '15 at 22:04
  • I'm completely unfamiliar with Objective C, but I'll try to convert it over and see – Noah Jul 25 '15 at 22:12
  • I'm not good enough with Objective C to figure out how that converts to swift. I don't even know if the classes are the same. – Noah Jul 25 '15 at 23:28
  • This isn't possible in Swift; radar 29368021 was filed and feel free to duplicate it. – iwasrobbed Aug 22 '18 at 19:10

1 Answers1

1

As far as I know, currently you cannot do it directly from XCUITest. So instead, maybe programmatically call it using launch arguments that then call the relevant section of the code to simulate the gesture. Not perfect, but the best way I know of currently (Apr 2019)

Charlie S
  • 4,366
  • 6
  • 59
  • 97