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

This assignment is focused on covering all the scenarios for User Registration for an e-commerce website. In this assignments you will learn the different Selenium commands which are used to handle the web form. A web form is generally a collection of web elements like, text boxes, radio buttons, selection box etc. And in web testing, we mostly face web forms and our 90% of testing revolves around web forms. We are going to cover both positive and negative scenarios for User Registration.

Assignment Level - Intermediate

Positive Scenario

Test Case 1 - Automate User Registration Process

Steps to Automate:
2. Click on sign in link.
3. Enter your email address in 'Create and account' section.
4. Click on Create an Account button.
5. Enter your Personal Information, Address and Contact info.
6. Click on Register button.
7. Validate that user is created.

If you find it difficult to automate above steps, then follow the reference link or take a look at the code shared below.

Reference Links for Solution :

Code for User Registration: Following 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 io.github.bonigarcia.wdm.WebDriverManager;

public class EcomSignUp {

 public static void main(String[] args) {
  WebDriver driver=new ChromeDriver();
  String URL="";

  driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
  //Click on Sign in
  driver.findElement(By.linkText("Sign in")).click();
  //Enter email address
  //Click on "Create an account"
  //Select Title
  driver.findElement("customer_firstname")).sendKeys("Test User");
  // Enter your address
  driver.findElement("firstname")).sendKeys("Test User");
  driver.findElement("address1")).sendKeys("Test 81/1,2nd cross");
  // Select State
  WebElement statedropdown=driver.findElement("id_state"));
  Select oSelect=new Select(statedropdown);

  // Select Country
  WebElement countrydropDown=driver.findElement("id_country"));
  Select oSelectC=new Select(countrydropDown);
  oSelectC.selectByVisibleText("United States");
  //Enter Mobile Number
  String userText=driver.findElement(By.xpath("//*[@id=\"header\"]/div[2]/div/div/nav/div[1]/a")).getText();

  // Validate that user has created
  if(userText.contains("Vsoft")) {
   System.out.println("User Verified,Test case Passed");
  else {
   System.out.println("User Verification Failed,Test case Failed");

Negative Scenarios
Test Case 2 - Verify invalid email address error.

Steps to Automate:
2. Click on sign in link.
3. Enter invalid email address in the email box and click enter.
4. Validate that an error message is displaying saying "Invalid email address."

Test Case 3 - Verify error messages for mandatory fields.

Steps to Automate:
2. Click on sign in link.
3. Enter email address and click Register button.
4. Leave the mandatory fields (marked with *) blank and click Register button.
5. Verify that error has been displayed for the mandatory fields.

Test Case 4 - Verify error messages for entering incorrect values in fields.

Steps to Automate:
2. Click on sign in link.
3. Enter email address and click Register button.
4. Enter incorrect values in fields like., enter numbers in first and last name, city field etc and enter alphabets in Mobile no, Zip postal code etc., and click on 'Register' button.
5. Verify that error messages fpr respective fields are displaying.
Try automating the above scenarios using Selenium commands, if you face any difficulty please refer the Selenium Tutorial series. Happy Learning!

Assignment 4- Automate Google Search << Previous | Next  >> Assignment 6- Automate Buy Product Functionality

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 Browser Actions on using Selenium

Automate E-Commerce Website using Selenium Webdriver