Accessibility testing : Descriptive transcript for pre-recorded audio

For pre-recorded audio (without video), provide a descriptive transcript that includes dialogue and all other meaningful sound.

Language: Java

Framework: Selenium 4

copy
1/​/​Assumptions: 2/​/​1. The pre-recorded audio file is stored on a web page and can be accessed through a URL.3/​/​2. The page on which the audio is located contains a text area or a container with an ID, where the transcript will be displayed.45import org.openqa.selenium.WebDriver;6import org.openqa.selenium.chrome.ChromeDriver;7import org.openqa.selenium.remote.DesiredCapabilities;8import org.openqa.selenium.remote.RemoteWebDriver;9import java.net.URL;101112public class AccessibilityTesting {1314 public static void main(String[] args) throws Exception {1516 /​/​Creating an instance of Chrome local driver17 System.setProperty("webdriver.chrome.driver", "path/​to/​chromedriver.exe");18 WebDriver driver = new ChromeDriver();1920 /​/​Code for Remote Driver with Desired Capabilities21 /​*DesiredCapabilities dc = DesiredCapabilities.chrome();22 WebDriver driver = new RemoteWebDriver(new URL("http:/​/​localhost:4444/​wd/​hub"), dc);*/​2324 /​/​Navigate to the page with the pre-recorded audio25 driver.navigate().to("[URL of the page with audio]");26 Thread.sleep(2000);2728 /​/​Locating the text area or container where the transcript will be displayed29 WebElement transcriptContainer = driver.findElement(By.id("[ID of the container]"));3031 /​/​Fetching the transcript using the Web Audio API32 JavascriptExecutor js = (JavascriptExecutor) driver;33 String transcript = (String) js.executeScript("return document.querySelectorAll('audio')[0].textTracks[0].cues[0].text;");3435 /​/​Displaying the transcript in the text area or container36 transcriptContainer.sendKeys(transcript);3738 /​/​Closing the browser window39 driver.quit();40 }41}

Language: Python

Framework: Selenium 4

copy
1from selenium import webdriver2from webdriver_manager.chrome import ChromeDriverManager34# Assuming the pre-recorded audio is available on a web page5url = "http:/​/​example.com/​pre-recorded-audio"67# Using Chrome driver locally8driver = webdriver.Chrome(ChromeDriverManager().install())910# To connect to remote client with desired capabilities, uncomment below code and provide the necessary details11# from selenium.webdriver.common.desired_capabilities import DesiredCapabilities12# capabilities = DesiredCapabilities.CHROME.copy()13# capabilities['platform'] = 'WINDOWS'14# capabilities['version'] = '10'15# driver = webdriver.Remote(command_executor='http:/​/​localhost:4444/​wd/​hub',16# desired_capabilities=capabilities)1718# Maximizing the browser window to ensure all elements are visible19driver.maximize_window()2021# Navigating to the page with pre-recorded audio22driver.get(url)2324# Assuming the descriptive transcript is available as an attribute of an element with id "audio-transcript"25audio_transcript = driver.find_element_by_id("audio-transcript").text2627# Asserting that the transcript contains dialogue and all other meaningful sounds28assert "dialogue" in audio_transcript29assert "meaningful sound" in audio_transcript3031# Closing the browser window after completing the test32driver.quit()

Disclaimer: Following code snippets and related information have been sourced from GitHub and/or generated using AI code generation tools. LambdaTest takes no responsibility in the accuracy of the code and is not liable for any damages.

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Power Your Software Testing with AI and cloud

Test Intelligently and ship faster. Deliver unparalleled digital experiences for real world enterprises.

Start Free Testing