BreadcrumbHomeResourcesBlog How To Test Voice Recognition In 4 Steps With Perfecto August 24, 2021 How to Test Voice Recognition in 4 Steps With PerfectoMobile Application TestingBy Johnny LamMany industries have recently started incorporating some form of voice assistant or voice recognition system as part of their mobile apps. Banking is one major industry that has made strides in this area, adopting virtual assistants to help customers save time on basic banking tasks. Retailers and grocery chains are hopping on the voice recognition bandwagon as well, incorporating major platforms such as Siri, Alexa, and Google Voice as another way to interact with customers.Source: T4.aiWhile voice assistants bring opportunities to developers, they pose new challenges for QA teams as they do their mobile testing. This blog post will give a detailed overview of Perfecto’s support of test cases for voice recognition systems. Table of Contents4 Steps to Testing Voice RecognitionFully Automated Voice Recognition Scenarios With PerfectoExample: Testing Google Voice With PerfectoBottom LineTable of Contents1 - 4 Steps to Testing Voice Recognition2 - Fully Automated Voice Recognition Scenarios With Perfecto3 - Example: Testing Google Voice With Perfecto4 - Bottom LineBack to top4 Steps to Testing Voice RecognitionAutomating voice assistant flows as part of your end to end testing can be achieved, in part, with an open-source automation framework such as Appium. There are four general steps to running automated tests for voice recognition software:Screen navigation to voice assistant (supported by Appium).Activate voice assistant (supported by Appium).Say a voice command (requires advanced automation).Validate screen/response (requires advanced automation). While automated tests can handle the first two steps, the last two are challenging to perform as part of an automated script. Traditional libraries such as Appium do not support audio out of the box.Back to topFully Automated Voice Recognition Scenarios With PerfectoFor teams that wish to completely automate their voice recognition scenarios, Perfecto offers additional APIs:Inject audio file. This allows testers to inject any audio file on a mobile device.Audio speech to text. This translates the audio output from a device back into text for validation.These additional audio capabilities enable teams to automate end to end test cases that include voice recognition with ease.Get started testing voice recognition with the industry's most-trusted web and mobile app testing platform. Try for FREE with our 14-day free trial.Start TestingBack to topExample: Testing Google Voice With PerfectoIn the following example, you’ll see how you can automate a simple end to end flow that includes Google Voice with Perfecto.There are three basic steps.Open a device.Click on Google Voice.Inject a pre-recorded audio file.For this sample script, we will be writing our code in Java and testNG.First, you open a device in the Perfecto lab. This example shows a user selecting a Samsung Galaxy S8. Next, use Perfecto’s “Object Spy,” which shows the application’s object properties, to access all the element locators. Once you are in Object Spy, you can locate all elements on the screen, including system level objects like the Google Voice icon. Then you can incorporate these locators as part of your automation script. Here is a sample snippet: driver.context("NATIVE_APP"); WebDriverWait wait = new WebDriverWait(driver, 30); AndroidElement voiceIcon = (AndroidElement) wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@resource-id=\"com.google.android.googlequicksearchbox:id/search_widget_voice_btn\"]")))); voiceIcon.click(); AndroidElement searchSong = (AndroidElement) wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@resource-id=\"com.google.android.googlequicksearchbox:id/display_text\"]")))); injectAudio(driver, "PRIVATE:example_text_1_plus_1.mp3"); Here’s the function responsible for the audio injection private static void injectAudio(AndroidDriver<AndroidElement> driver, String path) { Map<String, Object> params = new HashMap<>(); params.put("key", path); driver.executeScript("mobile:audio:inject", params); }Note that you can also upload your simple audio file to the Perfecto repository. You are now ready to execute your automated test in testNG and view your results in the Perfecto dashboard. When breaking down the test steps you can see exactly where the audio was injected and that the step passed successfully. Back to topBottom LineExecuting automated tests for voice recognition systems no longer needs to be a daunting task for QA. With Perfecto, teams can expand their test automation horizons with these additional audio capabilities at their fingertips.In addition to voice recognition system testing, Perfecto supports a wide range of advanced mobile testing capabilities. Geolocation testingTwo-factor authentication testingBiometric authentication testingImage injectionWatch Mobile Testing in ActionSee a demo of automated voice recognition system testing with Perfecto, as well as other advanced mobile testing capabilities that you would like to explore. Get DemoBack to top
Johnny Lam Director - Global Sales Engineering Johnny helps Fortune 500 enterprises and leading tech companies optimize and implement modern test automation strategies. With a software engineering background and over 10 years of experience embedded in development and testing teams, Johnny is both knowledgeable and passionate about improving testing efficiency and quality at scale.