// Set up WebDriver, assuming you have already downloaded and configured ChromeDriver System.setProperty("webdriver.chrome.driver", "path/to/chromedriver"); driver = new ChromeDriver(); }
// Add 2 quantities of each product in the VEG PIZZA section addProductToCart("Caprese Gourmet Pizza", 2); addProductToCart("Margherita", 2); addProductToCart("Peppy Paneer", 2);
// Add 12 quantities of Pepsi 475ml in the BEVERAGES section
addProductToCart("Pepsi 475ml", 12); }
public void assertCartSubtotalValue(double expectedSubtotal) {
double actualSubtotal = getCartSubtotalValue(); assert actualSubtotal == expectedSubtotal : "Assertion failed: Cart Subtotal value is not as expected."; }
public void removeProductsFromCart() {
// Remove 1 quantity of Margherita removeProductFromCart("Margherita", 1);
// Remove 6 quantities of Pepsi 475ml
removeProductFromCart("Pepsi 475ml", 6); }
public void getSubtotalAndClickCheckout() {
double subtotal = getCartSubtotalValue(); WebElement checkoutButton = driver.findElement(By.xpath("//button[text()='Check Out']")); checkoutButton.click(); // You can perform further actions on the Checkout page, such as filling in customer details, etc. }
public void assertSubtotalAtCheckoutWithPlaceOrderPriceDetails() {
double subtotalAtCheckout = getSubtotalAtCheckout(); double subtotalAtPlaceOrder = getSubtotalAtPlaceOrder(); assert subtotalAtCheckout == subtotalAtPlaceOrder : "Assertion failed: Subtotal value at checkout is not same as Subtotal value at Place Order Price Details."; }
public void tearDown() {
driver.quit(); }
private void addProductToCart(String productName, int quantity) {