This test case checks that the site's mobile checkout process is easy to use, ensuring that customers can complete their purchase easily and without any issues on their mobile device.
Language: Java
Framework: Selenium 4
1//Assumptions: The Shopify website URL is "https://www.shopify.com/"2//The mobile device is set to the 'Chrome' browser34import org.openqa.selenium.By;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.chrome.ChromeDriver;7import org.openqa.selenium.chrome.ChromeOptions;8import org.openqa.selenium.remote.DesiredCapabilities;9import org.openqa.selenium.remote.RemoteWebDriver;10import java.net.URL;1112public class ShopifyMobileCheckoutTest {1314 public static void main(String[] args) throws Exception {1516 //Local Driver17 System.setProperty("webdriver.chrome.driver", "./chromedriver");18 WebDriver driver = new ChromeDriver();1920 //Connect to Remote Client with Desired Capabilities21 /*22 DesiredCapabilities caps = new DesiredCapabilities().chrome();23 ChromeOptions options = new ChromeOptions();24 options.addArguments("--disable-dev-shm-usage");25 caps.setCapability(ChromeOptions.CAPABILITY, options);26 WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps);27 */2829 //Navigate to Shopify website30 driver.navigate().to("https://www.shopify.com/");3132 //Click on the 'Sign Up' button33 driver.findElement(By.xpath("//a[contains(text(),'Start free trial')]")).click();3435 //Check that the sign up form loads on the next page36 String signUpFormText = driver.findElement(By.xpath("//h1[contains(text(),'Sign up and start your store')]")).getText();37 if (signUpFormText.equals("Sign up and start your store")) {38 System.out.println("Signup form loaded successfully. Test case passed.");39 } else {40 System.out.println("Error loading signup form. Test case failed.");41 }4243 //Click on the 'View themes' button44 driver.findElement(By.xpath("//a[contains(text(),'View themes')]")).click();4546 //Check that the themes page loads on the next page47 String themesPageText = driver.findElement(By.xpath("//h1[contains(text(),'Top rated themes for your Shopify store')]")).getText();48 if (themesPageText.equals("Top rated themes for your Shopify store")) {49 System.out.println("Themes page loaded successfully. Test case passed.");50 } else {51 System.out.println("Error loading themes page. Test case failed.");52 }5354 //Click on the 'Pricing' button55 driver.findElement(By.xpath("//a[contains(text(),'Pricing')]")).click();5657 //Check that the pricing page loads on the next page58 String pricingPageText = driver.findElement(By.xpath("//h1[contains(text(),'Shopify pricing — Choose the plan that's right for')]")).getText();59 if (pricingPageText.equals("Shopify pricing — Choose the plan that's right for you")) {60 System.out.println("Pricing page loaded successfully. Test case passed.");61 } else {62 System.out.println("Error loading pricing page. Test case failed.");63 }6465 //Click on the 'Mobile app' button66 driver.findElement(By.xpath("//a[contains(text(),'Mobile app')]")).click();6768 //Check that the mobile app page loads on the next page69 String mobileAppPageText = driver.findElement(By.xpath("//h1[contains(text(),'The Shopify app — your mobile assistant')]")).getText();70 if (mobileAppPageText.equals("The Shopify app — your mobile assistant")) {71 System.out.println("Mobile app page loaded successfully. Test case passed.");72 } else {73 System.out.println("Error loading mobile app page. Test case failed.");74 }7576 //Close the browser77 driver.quit();78 }79}
Language: Python
Framework: Selenium 4
1from selenium import webdriver2from selenium.webdriver.common.keys import Keys3from selenium.webdriver.common.by import By4from selenium.webdriver.support.ui import WebDriverWait5from selenium.webdriver.support import expected_conditions as EC67#Assuming that the Shopify website uses responsive design that adapts to different screen sizes for mobile devices.89# Test case implementation using Local driver10# Setting up Chrome driver as the preferred browser11driver = webdriver.Chrome()1213# Navigating to the Shopify website14driver.get("https://www.shopify.com/")1516# Maximizing the browser window17driver.maximize_window()1819# Clicking on the 'Pricing' link in the navigation bar20pricing_link = WebDriverWait(driver, 10).until(21 EC.presence_of_element_located((By.LINK_TEXT, "Pricing")))22pricing_link.click()2324#Clicking on the 'Start free trial' button25start_free_trial_button = WebDriverWait(driver, 10).until(26 EC.presence_of_element_located((By.XPATH, "//a[@class='action btn btn-accent']")))27start_free_trial_button.click()2829# Entering the necessary details to start the free trial30name_input = WebDriverWait(driver, 10).until(31 EC.presence_of_element_located((By.ID, "account_first_name")))32name_input.send_keys("Test")33last_name_input = driver.find_element_by_id("account_last_name")34last_name_input.send_keys("User")35email_input = driver.find_element_by_id("account_email")36email_input.send_keys("testuser@test.com")37password_input = driver.find_element_by_id("account_password")38password_input.send_keys("testpassword")39store_name_input = driver.find_element_by_id("account_domain")40store_name_input.send_keys("test-store-name")41terms_checkbox = driver.find_element_by_id("terms-checkbox")42terms_checkbox.click()4344# Submitting the form to start the free trial45start_trial_submit_button = driver.find_element_by_name("commit")46start_trial_submit_button.click()4748# Navigating to the 'Themes' section of the Shopify dashboard49driver.get("https://test-store-name.myshopify.com/admin/themes")5051#Assuming that a default theme with a visible 'Mobile View' option exists in the Themes section of the Shopify dashboard.52#Clicking on the 'Mobile View' option for the default theme53mobile_view_link = WebDriverWait(driver, 10).until(54 EC.presence_of_element_located((By.XPATH, "//a[contains(text(),'Mobile view')]")))55mobile_view_link.click()5657#Assuming that the mobile checkout process is easy to use if the checkout form fields are well-labeled and there are no errors during submission.58#Checking for the presence of checkout form fields59checkout_field = WebDriverWait(driver, 10).until(60 EC.presence_of_element_located((By.XPATH, "//input[@id='checkout_email_or_phone']")))61checkout_field_label = driver.find_element_by_xpath("//label[@for='checkout_email_or_phone']")62# Verifying that the checkout form field is well-labeled63assert "Email or mobile phone number" in checkout_field_label.text6465#Entering the necessary details for the checkout form and submitting the form66checkout_field.send_keys("testuser@test.com")67checkout_submit_button = driver.find_element_by_id("continue_button")68checkout_submit_button.click()6970#Closing the browser window71driver.quit()7273# Code to connect to remote client with desired capabilities (Sample code)74# from selenium.webdriver.common.desired_capabilities import DesiredCapabilities75# desired_cap = DesiredCapabilities.CHROME76# desired_cap['platform'] = 'WINDOWS'77# desired_cap['version'] = 'latest'78# driver = webdriver.Remote(79# command_executor='http://localhost:4444/wd/hub',80# desired_capabilities=desired_cap)
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