This test case verifies that all shipping carrier integrations are operational and that there are no problems with shipping rate estimation or shipment tracking.
Language: Java
Framework: Selenium 4
1// Assumptions: 2// - The Shopify website has already been loaded in the browser.3// - The shipping carrier integrations are listed on a specific page.45import org.openqa.selenium.By;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.WebElement;8import org.openqa.selenium.chrome.ChromeDriver;9import org.openqa.selenium.remote.DesiredCapabilities;10import org.openqa.selenium.remote.RemoteWebDriver;11import java.net.URL;1213public class ShopifyCarrierIntegrationTest {1415 public static void main(String[] args) throws Exception {1617 // Running test on local driver18 System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");19 WebDriver driver = new ChromeDriver();20 driver.get("https://www.shopify.com/shipping/carriers");2122 // Verify that the page is loaded23 System.out.println("Page title is: " + driver.getTitle());2425 // Verify the number of shipping carrier integrations displayed26 WebElement integrationCount = driver.findElement(By.xpath("//span[@class='shipping-carriers__count']"));27 int count = Integer.parseInt(integrationCount.getText().trim());28 if (count > 0) {29 System.out.println("All shipping carrier integrations are operational.");30 } else {31 System.out.println("Shipping carrier integrations are not displaying properly.");32 }3334 // Verify shipping rate estimation and shipment tracking35 // (Assuming that these details are available on the carrier integration pages)36 for (int i = 1; i <= count; i++) {37 WebElement integration = driver.findElement(By.xpath("//div[@class='shipping-carriers__list']/div[" + i + "]"));38 integration.click();39 Thread.sleep(2000);40 String integrationTitle = driver.getTitle();41 if (integrationTitle.contains("Rate Estimation") && integrationTitle.contains("Shipment Tracking")) {42 System.out.println("Rate estimation and shipment tracking are operational for carrier integration #" + i);43 } else {44 System.out.println("Issues with rate estimation or shipment tracking for carrier integration #" + i);45 }46 driver.navigate().back();47 Thread.sleep(2000);48 }4950 // Running test on remote client with desired capabilities (Assuming the client is already set up)51 DesiredCapabilities capabilities = DesiredCapabilities.chrome();52 WebDriver remoteDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);53 remoteDriver.get("https://www.shopify.com/shipping/carriers");5455 // Verify that the page is loaded56 System.out.println("Page title is: " + remoteDriver.getTitle());5758 // Verify the number of shipping carrier integrations displayed59 WebElement remoteIntegrationCount = remoteDriver.findElement(By.xpath("//span[@class='shipping-carriers__count']"));60 int remoteCount = Integer.parseInt(remoteIntegrationCount.getText().trim());61 if (remoteCount > 0) {62 System.out.println("All shipping carrier integrations are operational.");63 } else {64 System.out.println("Shipping carrier integrations are not displaying properly.");65 }6667 // Verify shipping rate estimation and shipment tracking68 // (Assuming that these details are available on the carrier integration pages)69 for (int i = 1; i <= remoteCount; i++) {70 WebElement remoteIntegration = remoteDriver.findElement(By.xpath("//div[@class='shipping-carriers__list']/div[" + i + "]"));71 remoteIntegration.click();72 Thread.sleep(2000);73 String remoteIntegrationTitle = remoteDriver.getTitle();74 if (remoteIntegrationTitle.contains("Rate Estimation") && remoteIntegrationTitle.contains("Shipment Tracking")) {75 System.out.println("Rate estimation and shipment tracking are operational for carrier integration #" + i);76 } else {77 System.out.println("Issues with rate estimation or shipment tracking for carrier integration #" + i);78 }79 remoteDriver.navigate().back();80 Thread.sleep(2000);81 }8283 // Close the browser84 driver.quit();85 remoteDriver.quit();8687 }8889}
Language: Python
Framework: Selenium 4
1# Assumptions:2# - The webpage has a section dedicated to shipping carrier integrations3# - Each shipping carrier integration has a unique identifier4# - The shipping rate estimation and shipment tracking can be verified by interacting with the webpage56from selenium import webdriver7from selenium.webdriver.common.by import By8from selenium.webdriver.support.ui import WebDriverWait9from selenium.webdriver.support import expected_conditions as EC1011# Local driver setup12driver = webdriver.Chrome()1314# Remote client setup (uncomment for remote execution)15# from selenium.webdriver.common.desired_capabilities import DesiredCapabilities16# capabilities = DesiredCapabilities.CHROME.copy()17# driver = webdriver.Remote(18# command_executor='http://[REMOTE_HOST]:[REMOTE_PORT]/wd/hub',19# desired_capabilities=capabilities)2021# Go to Shopify webpage22driver.get("https://www.shopify.com/")2324# Navigate to shipping carrier integrations section25integrations_link = WebDriverWait(driver, 10).until(26 EC.presence_of_element_located((By.LINK_TEXT, "Shipping carrier integrations"))27)28integrations_link.click()2930# Verify shipping carrier integrations31integrations = WebDriverWait(driver, 10).until(32 EC.presence_of_all_elements_located((By.CLASS_NAME, "integration"))33)34for integration in integrations:35 integration_id = integration.get_attribute("id")36 # Assume that the integration is operational if it has no error messages37 integration_errors = integration.find_elements_by_class_name("error-message")38 assert len(integration_errors) == 0, f"Integration {integration_id} has errors: {integration_errors}"39 40# Verify shipping rate estimation and shipment tracking41# Assume that the verification involves interacting with the webpage in a way that exercises the functionality42# For example, adding a product to the cart and starting the checkout process4344# Close the browser window45driver.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.
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