Shopify webpage testing : Test site's customer account management

Verifying that the website's customer account management features, such as creating, editing, and deleting accounts, viewing order history, and tracking order status, are operational and that no errors are returned.

Language: Java

Framework: Selenium 4

copy
1/​*2Assumptions:3- The website's customer account management page has an accessible URL4- The website's customer account management page has valid input fields for creating and editing customer accounts5- The website's customer account management page displays order history and order status for logged-in customers6- The Selenium 4 Java bindings and the chromedriver executable are installed and added to the PATH environment variable7*/​8import org.openqa.selenium.By;9import org.openqa.selenium.WebDriver;10import org.openqa.selenium.WebElement;11import org.openqa.selenium.chrome.ChromeDriver;1213public class ShopifyCustomerAccountManagementTest {1415 public static void main(String[] args) {16 /​/​ Set the path to the chromedriver executable17 System.setProperty("webdriver.chrome.driver", "path/​to/​chromedriver");18 19 /​/​ Create a new ChromeDriver instance20 WebDriver driver = new ChromeDriver();21 22 /​/​ Navigate to the website's customer account management page23 driver.get("https:/​/​www.shopify.com/​customer-account-management");24 25 /​/​ Verify that the page title is correct26 assert driver.getTitle().equals("Customer Account Management | Shopify");27 28 /​/​ Login as a test user29 WebElement emailField = driver.findElement(By.id("email"));30 emailField.sendKeys("testuser@example.com");31 32 WebElement passwordField = driver.findElement(By.id("password"));33 passwordField.sendKeys("testpassword");34 35 WebElement loginButton = driver.findElement(By.id("login"));36 loginButton.click();37 38 /​/​ Verify that the login was successful39 assert driver.getCurrentUrl().equals("https:/​/​www.shopify.com/​customer-account-management/​dashboard");40 41 /​/​ Verify that creating a new account works42 /​/​ Assume valid input fields are present and accessible43 WebElement createAccountButton = driver.findElement(By.id("create-account"));44 createAccountButton.click();45 46 WebElement firstNameField = driver.findElement(By.id("first-name"));47 firstNameField.sendKeys("John");48 49 WebElement lastNameField = driver.findElement(By.id("last-name"));50 lastNameField.sendKeys("Doe");51 52 WebElement emailField2 = driver.findElement(By.id("email2"));53 emailField2.sendKeys("johndoe@example.com");54 55 WebElement passwordField2 = driver.findElement(By.id("password2"));56 passwordField2.sendKeys("johndoe123");57 58 WebElement confirmPasswordField = driver.findElement(By.id("confirm-password"));59 confirmPasswordField.sendKeys("johndoe123");60 61 WebElement createButton = driver.findElement(By.id("create"));62 createButton.click();63 64 assert driver.getCurrentUrl().equals("https:/​/​www.shopify.com/​customer-account-management");65 /​/​ Assume that a success message is displayed after account creation66 67 /​/​ Verify that editing an existing account works68 /​/​ Assume valid input fields are present and accessible69 WebElement editAccountButton = driver.findElement(By.id("edit-account"));70 editAccountButton.click();71 72 WebElement firstNameField2 = driver.findElement(By.id("first-name"));73 firstNameField2.clear();74 firstNameField2.sendKeys("Jane");75 76 WebElement saveButton = driver.findElement(By.id("save"));77 saveButton.click();78 79 assert driver.getCurrentUrl().equals("https:/​/​www.shopify.com/​customer-account-management");80 /​/​ Assume that a success message is displayed after account editing81 82 /​/​ Verify that deleting an existing account works83 WebElement deleteAccountButton = driver.findElement(By.id("delete-account"));84 deleteAccountButton.click();85 86 /​/​ Assume that a confirmation dialog is displayed87 WebElement confirmDeleteButton = driver.findElement(By.id("confirm-delete"));88 confirmDeleteButton.click();89 90 assert driver.getCurrentUrl().equals("https:/​/​www.shopify.com/​customer-account-management");91 /​/​ Assume that a success message is displayed after account deletion92 93 /​/​ Verify that viewing order history works94 WebElement orderHistoryButton = driver.findElement(By.id("order-history"));95 orderHistoryButton.click();96 97 assert driver.getCurrentUrl().equals("https:/​/​www.shopify.com/​customer-account-management/​order-history");98 /​/​ Assume that order history is displayed for the logged-in user99 100 /​/​ Verify that tracking order status works101 /​/​ Assume order tracking is available on the order history page102 WebElement orderTrackingButton = driver.findElement(By.id("track-order-status"));103 orderTrackingButton.click();104 105 /​/​ Assume that a valid order number is used for tracking106 WebElement orderNumberField = driver.findElement(By.id("order-number"));107 orderNumberField.sendKeys("123456");108 109 WebElement trackButton = driver.findElement(By.id("track"));110 trackButton.click();111 112 assert driver.getCurrentUrl().equals("https:/​/​www.shopify.com/​customer-account-management/​order-status?orderNumber=123456");113 /​/​ Assume that order status is displayed for the tracked order114 115 /​/​ Close the browser116 driver.quit();117 }118119} 120121/​/​ Uncomment the following code to use a remote client with desired capabilities122/​*123import org.openqa.selenium.remote.RemoteWebDriver;124import org.openqa.selenium.remote.DesiredCapabilities;125import java.net.URL;126127public class ShopifyCustomerAccountManagementTest {128129 public static void main(String[] args) throws Exception {130 /​/​ Specify the desired browser and platform capabilities131 DesiredCapabilities capabilities = DesiredCapabilities.chrome();132 capabilities.setCapability("platform", "Windows 10");133 capabilities.setCapability("version", "latest");134 135 /​/​ Create a new RemoteWebDriver instance136 WebDriver driver = new RemoteWebDriver(new URL("http:/​/​localhost:4444/​wd/​hub"), capabilities);137 138 /​/​ Test code here139 140 /​/​ Close the browser141 driver.quit();142 }143144} 145*/​

Language: Python

Framework: Selenium 4

copy
1# Assumptions: 2# 1. The Shopify webpage is loaded in Google Chrome browser 3# 2. The website's customer account management features are accessible and functional45# Importing required module6from selenium.webdriver import Chrome78# Setting up Chrome driver9driver = Chrome()1011# Navigating to the Shopify website12driver.get("https:/​/​www.shopify.com/​")1314# Clicking on 'Login' button to access customer account15login_button = driver.find_element_by_xpath("/​/​button[contains(text(),'Log in')]")16login_button.click()1718# Enter valid login credentials to access customer account19username_field = driver.find_element_by_id("account_email")20username_field.send_keys("testuser@email.com")2122password_field = driver.find_element_by_id("account_password")23password_field.send_keys("testpassword")2425# Clicking on 'Login' button to login26login_button = driver.find_element_by_name("commit")27login_button.click()2829# Checking if customer account management features are operational30# Creating a new account31create_account_button = driver.find_element_by_xpath("/​/​a[contains(text(),'Create account')]")32create_account_button.click()3334# Filling account information35first_name = drive.find_element_by_id("first_name")36first_name.send_keys("John")3738last_name = driver.find_element_by_id("last_name")39last_name.send_keys("Doe")4041email = driver.find_element_by_id("email")42email.send_keys("johndoe@email.com")4344password = driver.find_element_by_id("password")45password.send_keys("johndoe123")4647# Submitting new account form48submit_button = driver.find_element_by_xpath("/​/​button[contains(text(),'Create an account')]")49submit_button.click()5051# Editing an existing account52edit_account_button = driver.find_element_by_xpath("/​/​a[contains(text(),'Edit')]")53edit_account_button.click()5455# Editing account information56first_name = drive.find_element_by_id("first_name")57first_name.clear()58first_name.send_keys("Johnathan")5960last_name = driver.find_element_by_id("last_name")61last_name.clear()62last_name.send_keys("DoeV2")6364# Submitting updated account information65submit_button = driver.find_element_by_xpath("/​/​button[contains(text(),'Save')]")66submit_button.click()6768# Viewing order history69order_history_button = driver.find_element_by_xpath("/​/​a[contains(text(),'Order history')]")70order_history_button.click()7172# Checking order status73order_status_button = driver.find_element_by_xpath("/​/​a[contains(text(),'View order')]")74order_status_button.click()7576# Closing the driver77driver.quit() 7879# Code to connect to remote client with desired capabilities80# Assuming remote client is available at IP address: 192.168.0.1 81# and port: 444482from selenium.webdriver import Remote83from selenium.webdriver.common.desired_capabilities import DesiredCapabilities8485# Setting up desired capabilities for Chrome browser86desired_capabilities = DesiredCapabilities.CHROME.copy()8788# Connecting to remote client with desired capabilities89driver = Remote(90 command_executor="http:/​/​192.168.0.1:4444/​wd/​hub",91 desired_capabilities=desired_capabilities92)9394# Rest of the code can be copied from the above implementation with some minor changes based on the environment and connection.

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