Automate E-Commerce Website using Selenium Webdriver

In this post you will learn to automate different functionalities of e-commerce website. This assignment is rated as 'Pro' level. We will cover multiple test scenarios of e-commerce website in this assignment like., User Registration, Buy Product, Search Product and other website filters using Selenium Webdriver. Along with test assignments, url of the demo e-commerce website is also provided. You can use this demo e-com website for your automation practice.

Automation Level - Pro

Assignment 1 - Automate 'User Registration' of an e-commerce website

The first thing you test on any e-commerce website is User Registration. You have to cover all positive and negative test scenarios user registration process. You, will find the detailed test scenarios along with automation code at link shared below: Automate User Registration of E-Commerce Website using Selenium

Assignment 2 - Automate 'Buy Product' functionality of an e-commerce website

Most important functionality of an e-commerce website is buying a product, which includes various steps like select product, select size/color, add to cart, checkout etc. You will find every test scenario along with automation code at following link: Automate 'Buy Product' functionality of E-Commerce website using Selenium

Assignment 3 - Automate 'Search Product' functionality of an e-commerce website

Test Case 1- Automate 'Search Product' Functionality of an e-commerce website
Steps to Automate:
2. Move your cursor over Women's link.
3. Click on sub menu 'T-shirts'
4. Get Name/Text of the first product displayed on the page.
5. Now enter the same product name in the search bar present on top of page and click search button.
6. Validate that same product is displayed on searched page with same details which were displayed on T-Shirt's page.

If you find it difficult to automate above steps, then follow the reference link or you can also refer the code shared below in this post.

Reference Links for Solution :

Automation Code for Product Search: This code is contributed by Uday.

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import io.github.bonigarcia.wdm.WebDriverManager;

public class EcomPractice2 {
 public static void main(String[] args) throws InterruptedException{

  WebDriver driver=new ChromeDriver();
  String URL="";

  // Initialise Actions class object
  Actions actions=new Actions(driver);
  driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
  WebElement womenTab=driver.findElement(By.linkText("WOMEN"));
  WebElement TshirtTab=driver.findElement(By.xpath("//div[@id='block_top_menu']/ul/li[1]/ul/li[1]/ul//a[@title='T-shirts']"));
  // Get Product Name
  String ProductName=driver.findElement(By.xpath("/html[1]/body[1]/div[1]/div[2]/div[1]/div[3]/div[2]/ul[1]/li[1]/div[1]/div[2]/h5[1]/a[1]")).getText();
  // Get Name of Searched Product
  String SearchResultProductname=driver.findElement(By.xpath("/html[1]/body[1]/div[1]/div[2]/div[1]/div[3]/div[2]/ul[1]/li[1]/div[1]/div[2]/h5[1]/a[1]")).getText();

  // Verify that correct Product is displaying after search
  if(ProductName.equalsIgnoreCase(SearchResultProductname)) {
   System.out.println("Results Matched;Test Case Passed");
   System.out.println("Results NotMatched;Test Case Failed");
  // Close the browser


Happy Learning!

Assignment 6 - Automate Buy Product Functionality << Previous

    Follow Us

    Quora Space | Facebook Page | Telegram Channel
    Feel free to ask queries or share your thoughts in comments or email us.


    Popular posts from this blog

    10 Best Demo Websites for Automation Testing Practice

    Automate 'User Registration' of E-commerce Website using Selenium

    Automate Browser Actions on using Selenium