Get your setup working faster. Join our Discord for optimisation tips from elite testers.Join our Discord
Upload audio files and simulate microphone
This feature is currently a Private Beta service and available only under Desktop and Mobile Pro, and Enterprise Pro plans. For more details, check out our pricing page.
Audio Injection supports only Android 11 and above, Windows 10 and above, and macOS devices.
BrowserStack Automate enables you to upload audio files to your test sessions to verify various use cases, such as testing web apps that require access to microphone and audio output, linking the microphone to your web app, testing the microphone recording feature, etc.
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
The following table provides information about the enableAudioInjection capability:
Capability
Description
enableAudioInjection
Set this capability to "true" if you want to use your audio files in the test.
DesiredCapabilitiescapabilities=newDesiredCapabilities();HashMap<String,Object>browserstackOptions=newHashMap<String,Object>();// Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session.browserstackOptions.put("osVersion","12.0");browserstackOptions.put("deviceName","Samsung Galaxy S22");browserstackOptions.put("enableAudioInjection","true");capabilities.setCapability("bstack:options",browserstackOptions);
varcapabilities={'bstack:options':{// Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session."osVersion":"12.0","deviceName":"Samsung Galaxy S22""enableAudioInjection":"true"}}
Dictionary<string,object>browserstackOptions=newDictionary<string,object>();browserstackOptions.Add("enableAudioInjection","true");// Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session.browserstackOptions.Add("osVersion","12.0");browserstackOptions.Add("deviceName","Samsung Galaxy S22");capabilities.AddAdditionalOption("bstack:options",browserstackOptions);
desired_cap={'bstack:options':{# Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session.
"osVersion":"12.0","deviceName":"Samsung Galaxy S22","enableAudioInjection":"true",},}
capabilities={'bstack:options'=>{# Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session."osVersion"=>"12.0","deviceName"=>"Samsung Galaxy S22","enableAudioInjection"=>"true",},}
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
The following table provides information about the browserstack.enableAudioInjection capability:
Capability
Description
browserstack.enableAudioInjection
Set this capability to "true" if you want to use your audio files in the test.
DesiredCapabilitiesdesiredCapabilities=newDesiredCapabilities();desiredCapabilities.setCapability("browserstack.enableAudioInjection","true");// Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session.caps.setCapability("os_version","12.0");caps.setCapability("device","Samsung Galaxy S22");
varcapabilities={"browserstack.enableAudioInjection":"true"// Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session."os_version":"12.0","device":"Samsung Galaxy S22",}
ChromeOptionscapability=newChromeOptions();capability.AddAdditionalCapability("browserstack.enableAudioInjection","true");// Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session.capability.AddAdditionalCapability("os_version","12.0");capability.AddAdditionalCapability("device","Samsung Galaxy S22");
desired_cap={"browserstack.enableAudioInjection"="true",# Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session.
"os_version":"12.0","device":"Samsung Galaxy S22",}
caps=Selenium::WebDriver::Remote::Capabilities.newcaps["browserstack.enableAudioInjection"]="true"# Ensure to use Android version 11 or above. Passing an invalid version (below Android 11 or non-Android OS) drops the session.caps["os_version"]="12.0"caps["device"]="Samsung Galaxy S22"
Add audio injection logic for Android
The uploaded audio file is played on the remote device using custom JavaScript Executors. Your test script must be modified to add these custom executors along with the logic to click the UI element that in the webapp that triggers the microphone and plays the audio in a specified order.
Ensure that the following order is maintained in your script:
Specify the audio file to play during the test using the following custom executor. Set the audioUrl argument with the media_url you received on successful upload of the audio file.
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
The following table provides information about the enableAudioInjection capability:
Capability
Description
enableAudioInjection
Set this capability to "true" if you want to use your audio files in the test.
// Input capabilitiesvarcapabilities={'bstack:options':{"os":"Windows","osVersion":"10","projectName":"Audio Injection","buildName":"audio_test_1","userName":"YOUR_USERNAME","accessKey":"YOUR_ACCESS_KEY","enableAudioInjection":true,"audioInjectionURL":"media://575927ad18ae787c065e680dc3ee864725cd809e",},"browserName":"Chrome","browserVersion":"110.0",}// Your test logic
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
The following table provides information about the browserstack.enableAudioInjection capability:
Capability
Description
browserstack.enableAudioInjection
Set this capability to "true" if you want to use your audio files in the test.
The uploaded audio file is played manually on the remote device. Modify your test script to include steps to play audio in the web app UI, triggering the microphone and playing the audio in a specific order.
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
The following table provides information about the enableAudioInjection capability:
Capability
Description
enableAudioInjection
Set this capability to "true" if you want to use your audio files in the test.
// Input capabilitiesvarcapabilities={'bstack:options':{"os":"OS X","osVersion":"Monterey","browserVersion":"110.0","projectName":"Audio Injection","buildName":"audio_test_1","userName":"YOUR_USERNAME","accessKey":"YOUR_ACCESS_KEY","enableAudioInjection":true,"audioInjectionURL":"media://575927ad18ae787c065e680dc3ee864725cd809e",},"browserName":"Edge",}// Your test logic
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
The following table provides information about the browserstack.enableAudioInjection capability:
Capability
Description
browserstack.enableAudioInjection
Set this capability to "true" if you want to use your audio files in the test.
The uploaded audio file is played manually on the remote device. Modify your test script to include steps to play audio in the web app UI, triggering the microphone and playing the audio in a specific order.