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 org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import io.github.bonigarcia.wdm.WebDriverManager;

public class EcomSignUp {

 public static void main(String[] args) {
 
  WebDriverManager.chromedriver().setup();
  WebDriver driver=new ChromeDriver();
  String URL="http://automationpractice.com/index.php";

  driver.get(URL);
  driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
  driver.manage().window().maximize();
  
  //Click on Sign in
  driver.findElement(By.linkText("Sign in")).click();
  
  //Enter email address
  driver.findElement(By.cssSelector("[name='email_create']")).sendKeys("test1249@test.com");
  
  //Click on "Create an account"
  driver.findElement(By.xpath("//button[@name=\"SubmitCreate\"]")).click();
  
  //Select Title
  driver.findElement(By.xpath("//input[@id=\"id_gender1\"]")).click();
  driver.findElement(By.name("customer_firstname")).sendKeys("Test User");
  driver.findElement(By.name("customer_lastname")).sendKeys("Vsoft");
  driver.findElement(By.id("passwd")).sendKeys("PKR@PKR");
  
  // Enter your address
  driver.findElement(By.id("firstname")).sendKeys("Test User");
  driver.findElement(By.id("lastname")).sendKeys("Vsoft");
  driver.findElement(By.id("company")).sendKeys("Vsoft");
  driver.findElement(By.id("address1")).sendKeys("Test 81/1,2nd cross");
  driver.findElement(By.id("city")).sendKeys("XYZ");
  
  // Select State
  WebElement statedropdown=driver.findElement(By.name("id_state"));
  Select oSelect=new Select(statedropdown);
  oSelect.selectByValue("4");

  driver.findElement(By.name("postcode")).sendKeys("51838");
  
  // Select Country
  WebElement countrydropDown=driver.findElement(By.name("id_country"));
  Select oSelectC=new Select(countrydropDown);
  oSelectC.selectByVisibleText("United States");
  
  //Enter Mobile Number
  driver.findElement(By.id("phone_mobile")).sendKeys("234567890");
  driver.findElement(By.xpath("//input[@name=\"alias\"]")).clear();
  driver.findElement(By.xpath("//input[@name=\"alias\"]")).sendKeys("Office");
  driver.findElement(By.name("submitAccount")).click();
  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.

Comments

Popular posts from this blog

10 Best Demo Websites for Automation Testing Practice

Automate Browser Actions on Godaddy.com using Selenium

Automate E-Commerce Website using Selenium Webdriver