Shopify webpage testing : Check all payment gateway integrations

This test case verifies that all payment gateway integrations are functioning properly and that accepting payments and processing refunds are both working as intended.

Language: Java

Framework: Selenium 4

copy
1/​/​Assuming that the Shopify website has already been launched in the browser23/​/​Initializing the WebDriver for Chrome4WebDriver driver = new ChromeDriver();56/​/​Connecting to a remote client with desired capabilities7/​/​DesiredCapabilities capabilities = DesiredCapabilities.chrome();8/​/​WebDriver driver = new RemoteWebDriver(new URL("http:/​/​localhost:4444/​wd/​hub"), capabilities);910/​/​Locating the 'Payments' link on the website11WebElement paymentsLink = driver.findElement(By.linkText("Payments"));12paymentsLink.click();1314/​/​Locating the 'Select a Payment Method' section15WebElement paymentMethodsSection = driver.findElement(By.id("payment-methods"));1617/​/​Verifying that all payment gateway integrations are present18if(paymentMethodsSection.findElements(By.tagName("label")).size() == 4){19 System.out.println("All payment gateway integrations are present");20} else {21 System.out.println("One or more payment gateway integrations are missing");22}2324/​/​Selecting one payment method and making a payment25WebElement paymentMethod = driver.findElement(By.xpath("/​/​label[@for='payment-method-1']"));26paymentMethod.click();27WebElement continueButton = driver.findElement(By.xpath("/​/​button[@name='continue_button']"));28continueButton.click();2930/​/​Entering payment details31WebElement cardNumber = driver.findElement(By.xpath("/​/​input[@id='number']"));32cardNumber.sendKeys("1234567890123456");3334WebElement expiryDate = driver.findElement(By.xpath("/​/​input[@id='expiry']"));35expiryDate.sendKeys("12/​24");3637WebElement cvv = driver.findElement(By.xpath("/​/​input[@id='cvv']"));38cvv.sendKeys("123");3940/​/​Submitting the payment41WebElement submitButton = driver.findElement(By.xpath("/​/​button[@name='submit_button']"));42submitButton.click();4344/​/​Verifying that payment was successful and processing refund45WebElement paymentSuccessMessage = driver.findElement(By.xpath("/​/​div[@class='payment-success-message']"));46if(paymentSuccessMessage.isDisplayed()){47 System.out.println("Payment was successful");48 WebElement refundButton = driver.findElement(By.xpath("/​/​button[@name='refund_button']"));49 refundButton.click();50 System.out.println("Refund processed successfully");51} else {52 System.out.println("Payment was unsuccessful");53}5455/​/​Closing the WebDriver56driver.close();

Language: Python

Framework: Selenium 4

copy
1# Assumptions: Shopify webpage has all payment gateway integrations available.23# Import Selenium 4 libraries4from selenium.webdriver import Chrome5from selenium.webdriver.chrome.service import Service6from selenium.webdriver.common.by import By7from selenium.webdriver.support.ui import WebDriverWait8from selenium.webdriver.support import expected_conditions as EC910# Define driver path11driver_path = '/​path/​to/​chromedriver'1213# Local driver14driver = Chrome(service=Service(executable_path=driver_path))1516# Remote driver17# from selenium.webdriver import DesiredCapabilities18# capabilities = DesiredCapabilities.CHROME.copy()19# capabilities['version'] = '90.0'20# driver = Chrome(service_url='http:/​/​localhost:4444/​wd/​hub', desired_capabilities=capabilities)2122# Navigate to Shopify webpage23driver.get('https:/​/​www.shopify.com/​')2425# Click on Payment gateways link26payment_gateways_link = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.LINK_TEXT, 'Payment gateways')))27payment_gateways_link.click()2829# Verify payment gateways page is loaded30payment_gateways_page_title = 'Payment gateways – Shopify Help Center'31assert payment_gateways_page_title == driver.title3233# Get all payment gateways34payment_gateways = driver.find_elements(By.CSS_SELECTOR, '.ui-summary-list__item')35for gateway in payment_gateways:36 # Click on payment gateway37 gateway.click()38 39 # Verify payment gateway is loaded40 gateway_title = gateway.find_element(By.CSS_SELECTOR, 'a').text41 assert gateway_title == driver.title42 43 # Try to process payment44 payment_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[type="submit"]')))45 payment_button.click()46 47 # Verify payment is processed successfully48 success_message = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.ui-notice--success')))49 assert 'success' in success_message.text.lower()50 51 # Try to process refund52 refund_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[type="button"]')))53 refund_button.click()54 55 # Verify refund is processed successfully56 refund_success_message = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.ui-notice--success')))57 assert 'refund' in refund_success_message.text.lower()58 59 # Return to payment gateways page60 driver.back()61 62# Close the browser session63driver.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