Avoid requiring multipoint or path-based gestures (e.g., pinching, swiping, dragging) for functionality unless the gesture is essential to the functionality.
Language: Java
Framework: Selenium 4
1//Assuming we are testing a website or web application2//Assuming the website has functionality that requires gestures3//Assuming we are using a local driver45import org.junit.jupiter.api.Test;6import org.openqa.selenium.By;7import org.openqa.selenium.WebElement;8import org.openqa.selenium.WebDriver;9import org.openqa.selenium.chrome.ChromeDriver;1011public class GestureTest {1213@Test14public void testAvoidMultipointGestures() {15//set driver path to locate ChromeDriver.exe16//for Chrome browser version: 85.0.4183.8717//Change path according to your system environment18System.setProperty("webdriver.chrome.driver","C:\\drivers\\chromedriver.exe");1920// instantiate ChromeDriver object21WebDriver driver = new ChromeDriver();22//Launch the website we want to test23driver.get("https://www.testwebsite.com");2425//Assuming we want to test that the website does not require26//multipoint or path-based gestures for functionality27//We can assert that a certain element can be interacted with28//using only a single touch or click2930//Find the element we want to interact with31WebElement element = driver.findElement(By.id("login-button"));3233//Assuming the 'login-button' element can be clicked to login34//We will attempt to click the element and check if we are redirected35//to the login page or if there is an error message36element.click();3738//Assert that we are not redirected to the login page39//i.e. If there is an error message displayed on the page40//Assuming 'error-message' is the ID of the error message element41//we can check if it is displayed on the page to confirm42//that the login button did not require a multipoint gesture43assert!(driver.findElement(By.id("error-message")).isDisplayed());4445//Add code to connect to remote client with desired capabilities46//Assuming we want to run the test on an Android device47//with OS version 9 and resolution 1080x19204849//importing required libraries50import org.openqa.selenium.remote.DesiredCapabilities;51import org.openqa.selenium.remote.RemoteWebDriver;52import java.net.URL;5354//defining desired capabilities55DesiredCapabilities capabilities = new DesiredCapabilities();56capabilities.setCapability("platformName", "Android");57capabilities.setCapability("platformVersion", "9");58capabilities.setCapability("deviceName", "anyname");59capabilities.setCapability("appPackage", "com.example.testapp");60capabilities.setCapability("appActivity", ".MainActivity");6162//create RemoteWebDriver object and connect to the remote client63WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4723/wd/hub"), capabilities);6465}66}
Language: Python
Framework: Selenium 4
1# Assumptions2# - The application is a web app3# - The desired capability is to run tests on a desktop browser 4# - The access keys and URL are already provided56from selenium import webdriver7from selenium.webdriver.common.keys import Keys8from selenium.webdriver.common.action_chains import ActionChains9from selenium.webdriver.common.touch_actions import TouchActions10from selenium.webdriver.common.desired_capabilities import DesiredCapabilities1112# Connect to a remote client with desired capabilities13capabilities = DesiredCapabilities.CHROME.copy()14chrome_options = webdriver.ChromeOptions()15chrome_options.add_argument('--no-sandbox')16chrome_options.add_argument('--disable-dev-shm-usage')1718driver = webdriver.Remote(19 command_executor='http://REMOTE_CLIENT_IP:PORT/wd/hub',20 desired_capabilities=capabilities,21 options=chrome_options22 )2324# Set URL of the website25url = "https://www.example.com"2627# Step 1: Navigate to the website28driver.get(url)2930# Step 2: Find the element on the page where users might be required to perform 31# multipoint or path-based gestures and check whether it is essential to the functionality 32# - If it is essential, return a Pass status, else fail the test3334# Example Code to check if multipoint gesture is essential35# gesture_element = driver.find_element_by_xpath("//div[@class='multipoint-element']")36# if 'essential' in gesture_element.get_attribute('class'):37# print('Test Passed')38# else:39# print('Test Failed')4041# Close the browser42driver.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.
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