Accessibility testing : Avoid time limits for tasks

Do not require time limits to complete tasks unless absolutely necessary. If a time limit is necessary, the time limit should be at least 20 hours, or it can be extended, adjusted, or disabled.

Language: Java

Framework: Selenium 4

copy
1/​/​Assuming the web application has been loaded in the Chrome browser2/​/​Assuming the user has logged in and is on the page where tasks are assigned34import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.By;89public class AccessibilityTesting {10 public static void main(String[] args) {1112 /​/​Set System Property to use Chrome driver13 System.setProperty("webdriver.chrome.driver", "/​path/​to/​chromedriver"); /​/​path to chromedriver.exe1415 /​/​Create a new Chrome Driver16 WebDriver driver = new ChromeDriver();1718 /​/​Navigate to the URL of the page where tasks are assigned19 driver.get("https:/​/​example.com/​tasks");2021 /​/​Check for time limits on tasks22 WebElement taskElement = driver.findElement(By.name("task"));23 String taskTimeLimit = taskElement.getAttribute("timelimit");2425 /​/​If the timelimit exists, check if it's at least 20 hours, or it can be extended, adjusted, or disabled26 if (taskTimeLimit != null) {27 int timeLimit = Integer.parseInt(taskTimeLimit);2829 if (timeLimit < 20) {30 System.out.println("Time limit is less than 20 hours");31 } else {32 System.out.println("Time limit is at least 20 hours");33 }34 } else {35 System.out.println("No time limit set for task");36 }3738 /​/​Close the browser39 driver.quit();40 }41}4243/​/​Code to use remote client with desired capabilities44/​/​Assuming we want to run the test on a remote machine with Firefox browser4546import org.openqa.selenium.WebDriver;47import org.openqa.selenium.remote.DesiredCapabilities;48import org.openqa.selenium.remote.RemoteWebDriver;49import java.net.URL;5051public class AccessibilityTesting {52 public static void main(String[] args) throws Exception {5354 /​/​Set the Desired Capabilities for Firefox55 DesiredCapabilities capabilities = DesiredCapabilities.firefox();5657 /​/​Create a URL for the remote machine58 URL url = new URL("http:/​/​192.168.1.1:4444/​wd/​hub");5960 /​/​Create a new Remote WebDriver for Firefox61 WebDriver driver = new RemoteWebDriver(url, capabilities);6263 /​/​Navigate to the URL of the page where tasks are assigned64 driver.get("https:/​/​example.com/​tasks");6566 /​/​Check for time limits on tasks67 ....6869 /​/​Close the browser70 driver.quit();71 }72}

Language: Python

Framework: Selenium 4

copy
1#Assumptions:2#1. The web application has a functionality that requires users to complete tasks with time limits.3#2. We have access to the source code of the application to make necessary changes.45#Code to implement the test case in Python using Selenium 467from selenium import webdriver8from selenium.webdriver.common.keys import Keys910#Using Chrome driver and assuming it is installed11driver = webdriver.Chrome()1213#Connecting to remote client with desired capabilities14'''15from selenium.webdriver.common.desired_capabilities import DesiredCapabilities1617#Define desired capabilities for remote connection18desired_cap = {19 'browserName': 'chrome',20 'version': '91.0',21 'platform': 'WINDOWS',22}2324driver = webdriver.Remote(25 command_executor='http:/​/​localhost:4444/​wd/​hub',26 desired_capabilities=desired_cap27)28'''2930#Navigate to the web application URL31driver.get("https:/​/​www.example.com")3233#Check if the application has time limits set for tasks34if driver.find_element_by_xpath("/​/​span[contains(text(),'Time limit')]").is_displayed():35 #Get the time limit set for tasks36 time_limit = driver.find_element_by_xpath("/​/​span[contains(text(),'Time limit')]/​following-sibling::span").text37 time_limit_in_hours = int(time_limit.split()[0]) #assuming time limit is in hours38 #Check if the time limit is less than 20 hours39 if time_limit_in_hours < 20:40 assert False, "Time limit is less than 20 hours"41else:42 print("No time limit set for tasks")4344#Close the browser window45driver.close()

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