Shopify webpage testing : Verify that all links and buttons

This test case checks that all links and buttons are easily accessible on mobile devices, ensuring that customers can navigate the site easily and complete actions such as adding items to their cart or placing an order.

Language: Java

Framework: Selenium 4

copy
1/​/​Assuming the web application is a Shopify shopping website2/​/​Assuming the application is being tested on a mobile device34import org.openqa.selenium.By;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.chrome.ChromeDriver;8import org.openqa.selenium.chrome.ChromeOptions;910public class ShopifyMobileValidation {1112public static void main(String[] args) {1314/​/​Setting Desired Capabilities to run tests on remote client15ChromeOptions options = new ChromeOptions();16options.addArguments("start-maximized");17options.addArguments("enable-automation");18options.addArguments("--no-sandbox");19options.addArguments("--disable-infobars");20options.addArguments("--disable-dev-shm-usage");21options.addArguments("--disable-browser-side-navigation");22options.addArguments("--disable-gpu");23options.setExperimentalOption("useAutomationExtension", false);2425/​/​Initializing local driver26System.setProperty("webdriver.chrome.driver", "/​path/​to/​chromedriver");27WebDriver driver = new ChromeDriver(options);2829/​/​Navigate to the Shopify website30driver.get("https:/​/​www.shopify.com/​");3132/​/​Locate all the links and buttons on the webpage33List<WebElement> links = driver.findElements(By.tagName("a"));34List<WebElement> buttons = driver.findElements(By.tagName("button"));3536/​/​Iterate through each element to check accessibility37for (WebElement link : links) {38String url = link.getAttribute("href");39if (url != null && !url.contains("javascript")) {40/​/​verify if the link is clickable41}42}4344for (WebElement button : buttons) {45if (button.isDisplayed() && button.isEnabled()) {46/​/​verify if the button is clickable47}48}4950/​/​Close the browser51driver.close();52}53}

Language: Python

Framework: Selenium 4

copy
1# Assumptions:2# - The Shopify webpage is accessible at the URL specified in the test environment.3# - The webpage is mobile responsive and can be easily accessed on any mobile device.4# - All links and buttons on the page have a unique ID or CSS selector that can be used to locate them.56from selenium import webdriver7from selenium.webdriver.common.by import By89# Define the test environment and desired capabilities10options = webdriver.ChromeOptions()11options.add_argument('--disable-extensions')12options.add_argument('--start-maximized')1314# Local driver15driver = webdriver.Chrome(options=options, executable_path="./​chromedriver")1617# Remote client with desired capabilities18# driver = webdriver.Remote(19# command_executor='http:/​/​<REMOTE_ADDRESS>/​wd/​hub',20# desired_capabilities=DesiredCapabilities.CHROME.copy())2122# Navigate to the Shopify webpage23driver.get("https:/​/​www.shopify.com/​")2425# Find all links and buttons on the page26elements = driver.find_elements(By.XPATH, "/​/​a|/​/​button")2728# Loop through each element and ensure it is clickable29for element in elements:30 assert element.is_enabled(), f"Element {element.tag_name} with text '{element.text}' is not clickable."3132# Close the driver33driver.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