Accessibility testing : Provide navigation aids for related pages

Each website should include at least two of the following: a list of related pages; table of contents; site map; search; or list of all pages.

Language: Java

Framework: Selenium 4

copy
1/​/​Assumptions:2/​/​1. Web application is using Selenium 43/​/​2. The page includes navigation elements like related pages, table of contents, and a site map4/​/​3. The web application is running locally on the system5/​/​4. Java version 8 is installed on the system67import org.openqa.selenium.By;8import org.openqa.selenium.WebDriver;9import org.openqa.selenium.WebElement;10import org.openqa.selenium.chrome.ChromeDriver;1112public class AccessibilityTesting {13 14 public static void main(String[] args) {15 16 /​/​ Set WebDriver to use local chrome driver17 System.setProperty("webdriver.chrome.driver", "path/​to/​chrome/​driver");18 WebDriver webDriver = new ChromeDriver();19 20 /​/​ URL of the website being tested21 String websiteURL = "https:/​/​www.example.com";22 23 /​/​ Navigate to the website24 webDriver.get(websiteURL);25 26 /​/​ Check if the website contains navigation aids like related pages, table of contents, and site map27 WebElement relatedPages = webDriver.findElement(By.id("related-pages"));28 WebElement tableOfContents = webDriver.findElement(By.id("table-of-contents"));29 WebElement siteMap = webDriver.findElement(By.id("site-map"));3031 /​/​ Assert if navigation aids are present on the website32 if (relatedPages.isDisplayed() && tableOfContents.isDisplayed() && siteMap.isDisplayed()) {33 System.out.println("Navigation aids are present on the website");34 } else {35 System.out.println("Navigation aids are not present on the website");36 }37 38 /​/​Add commented code to connect to remote client with desired capabilities39 /​*40 DesiredCapabilities capabilities = new DesiredCapabilities();41 capabilities.setCapability("browserName", "chrome");42 RemoteWebDriver webDriver = new RemoteWebDriver(new URL("http:/​/​localhost:4444/​wd/​hub"), capabilities);43 */​44 45 webDriver.quit(); /​/​Close the browser window46 }47}

Language: Python

Framework: Selenium 4

copy
1from selenium import webdriver2from selenium.webdriver.common.keys import Keys34#Assumptions:5#1. The web page has a menu bar/​menu links.6#2. All related pages are linked in the menu/​navigation links.7#3. All the navigation aids mentioned in the description are available in the web page.89#Connecting to the local driver10driver = webdriver.Chrome()1112#Connecting to remote client using desired capabilities (uncomment code below to use remote client)13# from selenium.webdriver.common.desired_capabilities import DesiredCapabilities14# driver = webdriver.Remote(command_executor='<remote client url>', desired_capabilities=DesiredCapabilities.CHROME)1516#Opening the website URL17driver.get("https:/​/​www.example.com")1819#Locating navigation aids20related_pages = driver.find_element_by_link_text("Related Pages")21table_of_contents = driver.find_element_by_link_text("Table of Contents")22site_map = driver.find_element_by_link_text("Site Map")23search = driver.find_element_by_xpath("/​/​input[@id='search']")24list_of_all_pages = driver.find_element_by_link_text("List of All Pages")2526#Verifying the presence of each navigation aid27assert related_pages.is_displayed() == True, "Related Pages navigation aid not found"28assert table_of_contents.is_displayed() == True, "Table of Contents navigation aid not found"29assert site_map.is_displayed() == True, "Site Map navigation aid not found"30assert search.is_displayed() == True, "Search navigation aid not found"31assert list_of_all_pages.is_displayed() == True, "List of All Pages navigation aid not found"3233#Closing the browser34driver.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