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.
DesiredCapabilities capabilities =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);
var 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"}}
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.
DesiredCapabilities desiredCapabilities =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");
var capabilities ={"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",}
ChromeOptions capability =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.new
caps["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 capabilitiesvar capabilities ={'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.
var capabilities ={"os":"Windows","os_version":"10","browserName":"Chrome","browser_version":"110.0","browserstack.enableAudioInjection":"true","browserstack.audioInjectionURL":"media://575927ad18ae787c065e680dc3ee864725cd809e","browserstack.user":"USERNAME","browserstack.key":"ACCESS_KEY"}
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.
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
platforms:-os: OS X
osVersion: Sonoma
browserName: Chrome
browserVersion:110.0projectName: Audio Injection
buildName: audio_test_1
enableAudioInjection:trueaudioInjectionURL: media://575927ad18ae787c065e680dc3ee864725cd809e
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 capabilitiesvar capabilities ={'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.
var capabilities ={"os":"OS X","os_version":"Monterey","browserName":"Edge","browser_version":"108.0","browserstack.enableAudioInjection":"true","browserstack.audioInjectionURL":"media://575927ad18ae787c065e680dc3ee864725cd809e","browserstack.user":"USERNAME","browserstack.key":"ACCESS_KEY"}
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.
Related topics
Check this page for a list of various JavaScript Executors that BrowserStack offers.
Did this page help you?
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked