Shopify webpage testing : Verify that the checkout process is secure

This test case ensures that the checkout process is secure and that sensitive customer information is properly encrypted.

Language: Java

Framework: Selenium 4

copy
1/​/​Assuming the checkout page loads after adding items to the cart and clicking on checkout button23/​/​Using local driver4WebDriver driver = new ChromeDriver();5driver.manage().window().maximize();6driver.get("https:/​/​www.shopify.com");78/​/​Locating login button and clicking it9WebElement loginButton = driver.findElement(By.xpath("/​/​a[@class='btn uppercase btn--white hide--until-medium show--until-medium js-header-social-auth__link js-social-auth__link']"));10loginButton.click();1112/​/​Entering login credentials and submitting13WebElement emailInput = driver.findElement(By.id("account_email"));14emailInput.sendKeys("example@email.com");15WebElement passwordInput = driver.findElement(By.id("account_password"));16passwordInput.sendKeys("password");17WebElement loginSubmitButton = driver.findElement(By.xpath("/​/​input[@class='btn']"));18loginSubmitButton.click();1920/​/​Assuming items have already been added to cart and check out button clicked21/​/​Locating check out button and clicking it22WebElement checkoutButton = driver.findElement(By.xpath("/​/​button[@type='submit']"));23checkoutButton.click();2425/​/​Verifying the URL contains https which signifies a secure connection26String url = driver.getCurrentUrl();27if(url.contains("https")) {28 System.out.println("Checkout process is secure");29} else {30 System.out.println("Checkout process is not secure");31}3233/​/​Using remote client with desired capabilities34DesiredCapabilities capabilities = new DesiredCapabilities();35capabilities.setBrowserName("chrome");36capabilities.setPlatform(Platform.WIN10);3738WebDriver driver = new RemoteWebDriver(new URL("http:/​/​localhost:4444/​wd/​hub"), capabilities);39driver.manage().window().maximize();40driver.get("https:/​/​www.shopify.com");

Language: Python

Framework: Selenium 4

copy
1from selenium import webdriver2from selenium.webdriver.common.by import By3from selenium.webdriver.support.ui import WebDriverWait4from selenium.webdriver.support import expected_conditions as EC56# Assuming the Shopify webpage URL is known7shopify_url = "https:/​/​www.shopify.com"89# Assuming the checkout process can be accessed via a 'Checkout' button10checkout_btn_locator = (By.XPATH, "/​/​button[text()='Checkout']")1112# Driver for local execution13driver = webdriver.Chrome()1415# Uncomment below code to connect to remote client with desired capabilities16"""17from selenium.webdriver.common.desired_capabilities import DesiredCapabilities1819capabilities = DesiredCapabilities.CHROME.copy()20capabilities['version'] = 'latest'21capabilities['platform'] = 'WIN10'2223driver = webdriver.Remote(24 command_executor='http:/​/​192.168.0.1:4444/​wd/​hub',25 desired_capabilities=capabilities26)27"""2829# Open the Shopify webpage30driver.get(shopify_url)3132# Maximizing the browser window to ensure that all elements are loaded33driver.maximize_window()3435# Wait for the 'Checkout' button to be visible and clickable36checkout_btn = WebDriverWait(driver, 10).until(37 EC.element_to_be_clickable(checkout_btn_locator)38)3940# Click the 'Checkout' button41checkout_btn.click()4243# Assuming that the checkout process includes filling in customer information and payment details44# Verifying that the elements to capture customer information and payment details are present and enabled4546# Capturing the 'Email' input element for customer information47customer_email_locator = (By.ID, "customer_email")48customer_email_input = WebDriverWait(driver, 10).until(49 EC.presence_of_element_located(customer_email_locator)50)51assert customer_email_input.is_enabled(), "Email input for customer information is not enabled"5253# Capturing the 'Card Number' input element for payment details54card_number_locator = (By.ID, "card_number")55card_number_input = WebDriverWait(driver, 10).until(56 EC.presence_of_element_located(card_number_locator)57)58assert card_number_input.is_enabled(), "Card Number input for payment details is not enabled"5960# Assuming that the checkout process includes a secure connection (https)61# Verifying that the webpage is loaded securely62secure_connection = driver.execute_script("""63 return document.querySelector('div[class="addressBar"]').getAttribute('class') === 'addressBar isSecure'64""")65assert secure_connection, "The webpage is not loaded securely"6667# Assuming that the checkout process includes encryption of sensitive customer information68# Verifying that the sensitive customer information is properly encrypted69encrypted_info = driver.execute_script("""70 return document.querySelector('div[class="addressBar"]').getAttribute('class') === 'addressBar isSecure'71""")72assert encrypted_info, "Sensitive customer information is not properly encrypted"7374# Closing the browser window75driver.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