Accessibility testing : Content and functionality preservation during text resizing

Ensure that there is no loss of content or functionality when text resizes.

Language: Java

Framework: Selenium 4

copy
1Assuming the webpage is accessible, here is the code to implement the test case to check if content and functionality can be preserved during text resizing using Selenium 4 in Java:23```4/​/​ Connect to local driver5WebDriver driver = new ChromeDriver();67/​/​ Alternatively, connect to remote client with desired capabilities8/​**9DesiredCapabilities capabilities = new DesiredCapabilities();10capabilities.setPlatform(Platform.MAC);11capabilities.setBrowserName("Chrome");12capabilities.setVersion("91.0");13WebDriver driver = new RemoteWebDriver(new URL("http:/​/​localhost:4444/​wd/​hub"), capabilities);14**/​1516/​/​ Navigate to the webpage17driver.get("https:/​/​example.com");1819/​/​ Resize the text (assuming webpage can be resized with keyboard shortcut Ctrl + "+")20driver.findElement(By.tagName("body")).sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));2122/​/​ Verify page content and functionality is preserved23/​/​ Assuming the webpage has a dynamically changing element with id="button", and content with class="content"24String expectedContent = "example text";25String actualContent = driver.findElement(By.className("content")).getText();2627Assert.assertEquals("Error: Text resizing caused content loss", expectedContent, actualContent);2829Boolean buttonDisplayed = driver.findElement(By.id("button")).isDisplayed();3031Assert.assertTrue("Error: Text resizing caused functionality loss", buttonDisplayed);3233/​/​ Close the driver34driver.quit();35```3637Note: This assumes that the webpage can be resized using a keyboard shortcut (e.g. Ctrl + "+") and that the webpage contains a dynamically changing element with an id of "button" and content with a class of "content". Additionally, the remote client connection code is commented out and will need to be uncommented and modified as needed if a remote client is used.

Language: Python

Framework: Selenium 4

copy
1from selenium import webdriver2from selenium.webdriver.common.keys import Keys3from selenium.webdriver.chrome.service import Service as ChromeService4from selenium.webdriver.common.desired_capabilities import DesiredCapabilities56#Assuming the website we are testing is www.example.com7url = "www.example.com"89#Assuming we are connecting to a remote client10#Set desired capabilities11chrome_options = webdriver.ChromeOptions()12chrome_options.add_argument('--disable-dev-shm-usage')13chrome_options.add_argument('--no-sandbox')14chrome_options.add_argument('--headless')15chrome_options.add_argument('--disable-gpu')16capabilities = DesiredCapabilities.CHROME.copy()17capabilities.update(chrome_options.to_capabilities())1819#Set remote web driver20webdriver.Remote(command_executor='http:/​/​localhost:4444/​wd/​hub',21 desired_capabilities= capabilities)2223#Set local web driver24driver = webdriver.Chrome(service=ChromeService(executable_path='/​path/​to/​chromedriver'))2526#Maximize window27driver.maximize_window()2829#Navigate to the website30driver.get(url)3132#Locate the element to resize33element = driver.find_element_by_xpath("/​/​p")3435#Get the initial size of the element36initial_size = element.size3738#Assuming that the user resizes the text to a larger size39element.send_keys(Keys.CONTROL, "+")4041#Get the new size of the element42new_size = element.size4344#Check if the content and functionality is preserved45assert initial_size == new_size, "Content and functionality is not preserved during text resizing" 4647#Close the browser window48driver.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