logo logo

Testing Siri Integration with the New Siri Command Addon

iOS commands addon

One of iOS’s commonly used features is the voice-controlled AI assistant named “Siri.” Siri can be used for lots of things, including integration with your own apps via SiriKit, to provide voice-activated shortcuts. It’s therefore important to be able to test Siri and its integration with your devices. Appium makes this possible via a special executeScript command, “mobile: siriCommand”, which takes a single parameter (namely the “voice” command that Siri should receive). This triggers an internal API that makes it as if Siri received the command via the user’s voice (though no actual audio is involved with this method). For more information about Appium and Siri, check out my post on Appium Pro.

My new Siri Command for iOS Addon basically provides access to this Appium + iOS feature. As expected, it’s a global (not element-specific action) that runs only on iOS device tests. And it takes a single string parameter. You can put anything in here that you like; in my testing, I used the example “What is two plus two?” to trigger Siri’s internal logic to answer a math question. The response shows up on the screen in two parts: First a reformulation of the question (“2 + 2 =“) and then the answer itself (“4”). The fact that these show up on the screen (and not just via audio output) and are moreover backed by accessibility IDs makes it easy to verify that Siri’s response to my command was appropriate.

The source code for this addon is open source, up on GitHub (https://github.com/testproject-io/addons/tree/master/siri). You can see that its implementation is quite simple, since all it does is leverage the TestProject SDK to acquire the correct parameter from the TestProject user, and then pass this in to the “mobile: siriCommand” Appium command using the Appium driver object provided by the TestProject SDK.

So that’s it! Check out the addon itself at the TestProject addons library here.

Which kind of Addon would you like to see next? Share your ideas in the comments below! 😉


About the author

Jonathan Lipps

Jonathan has been making things out of code as long as he can remember. Jonathan is the architect and project lead for Appium, the popular open source automation framework. He is also the founding Principal of Cloud Grey, a consulting firm devoted to helping clients leverage the power of Appium successfully. He has worked as a programmer in tech startups for over 15 years, but is also passionate about academic discussion. Jonathan has master’s degrees in philosophy and linguistics, from Stanford and Oxford respectively. Living in Vancouver, he’s an avid musician, and also writes on the philosophy of technology.

Jonathan also writes the weekly newsletter and blog Appium Pro, which delivers fantastic Appium-related tips and tutorials straight to your inbox every Wednesday.

Leave a Reply