Items on the page should not automatically move, blink, scroll, or update, including carousels. If content does automatically move, blink, scroll, or update, provide a way to pause, stop, or hide the moving, blinking, scrolling, or updating.
Language: Java
Framework: Selenium 4
1//Assuming the current environment is a web application2//Assuming the current webpage has a carousel which should not auto-move, blink, scroll or update34import org.openqa.selenium.*;5import org.openqa.selenium.chrome.ChromeDriver;67public class AccessibilityTesting {8 public static void main(String[] args) throws InterruptedException {910 //Set the path of ChromeDriver11 System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");1213 //Create a new instance of the Chrome driver14 WebDriver driver = new ChromeDriver();1516 //Navigate to the webpage17 driver.navigate().to("https://example.com");1819 //Maximize the browser window20 driver.manage().window().maximize();2122 //Get the carousel element23 WebElement carousel = driver.findElement(By.id("carousel1"));2425 //Check if carousel auto-moves, blinks, scrolls or updates26 if (carousel.getAttribute("autoplay").equals("true")) {27 System.out.println("Error: Carousel auto-moves");28 }29 if (carousel.getCssValue("animation-name").equals("blinking")) {30 System.out.println("Error: Carousel blinks");31 }32 if (carousel.getCssValue("overflow-y").equals("scroll")) {33 System.out.println("Error: Carousel scrolls");34 }3536 //Pause, stop or hide the moving, blinking, scrolling or updating37 WebElement pauseButton = driver.findElement(By.id("pauseBtn"));38 pauseButton.click();3940 //Close the browser window41 driver.quit();42 }43 //Connect to remote client with desired capabilities44 //Assuming the remote client is a grid with Firefox and Edge drivers45 public void remoteDriver() {46 DesiredCapabilities capabilities = new DesiredCapabilities();47 capabilities.setBrowserName("firefox");48 capabilities.setVersion("92.0");4950 WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);5152 capabilities.setBrowserName("MicrosoftEdge");53 capabilities.setVersion("44.18362.1.0");54 driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);5556 driver.quit();57 }58}
Language: Python
Framework: Selenium 4
1from selenium import webdriver2from selenium.webdriver.chrome.options import Options3from selenium.webdriver.common.desired_capabilities import DesiredCapabilities45# Set browser options6chrome_options = Options()7chrome_options.add_argument('--disable-extensions')8chrome_options.add_argument('--disable-geolocation')9chrome_options.add_argument('--disable-infobars')10chrome_options.add_argument('--disable-notifications')11chrome_options.add_argument('--disable-web-security')12chrome_options.add_argument('--disable-xss-auditor')13chrome_options.add_argument('--enable-javascript')14chrome_options.add_argument('--incognito')15chrome_options.add_argument('--start-maximized')1617# Set desired capabilities for remote client18desired_caps = DesiredCapabilities.CHROME.copy()19desired_caps['enableVNC'] = True20desired_caps['enableVideo'] = False2122# Create local driver23driver = webdriver.Chrome(options=chrome_options)2425# Uncomment to connect to remote client with desired capabilities26# driver = webdriver.Remote(27# command_executor='http://localhost:4444/wd/hub',28# desired_capabilities=desired_caps,29# options=chrome_options30# )3132# Navigate to page to test33driver.get('http://example.com')3435# Check for auto-moving, blinking, scrolling, or updating content36if driver.execute_script('return window.getComputedStyle(arguments[0]).getPropertyValue("animation-name")', driver.find_element_by_xpath('//body')) != 'none':37 # Pause, stop, or hide the moving, blinking, scrolling, or updating content38 driver.execute_script('arguments[0].style.animationPlayState = "paused"', driver.find_element_by_xpath('//body'))
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.
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.
Test Intelligently and ship faster. Deliver unparalleled digital experiences for real world enterprises.
Start Free Testing