Selenium Practice Form

AUTOMATE ME


First name: 

Last name: 
Gender   Male    
Years of Experience 1    2    3    4    5    6    

Date: 

Profession  Manual Tester    

Automation Tools   UFT   Protractor   Selenium Webdriver
Continents
Selenium Commands

Upload Image 




How to automate "Practice Form" with Selenium


This is a demo web form which contains all the form elements which are mostly present on any web page. So, by automating this form you would learn all the webdriver commands which are required to automate a web page. 

This web from contains following web elements:
  • Links
  • Text boxes
  • Radio buttons
  • Date Picker
  • Check boxes
  • Select box
  • Multi Select box
  • Upload Image button
  • Download link
Steps to automate:
  1. Open this link - https://www.techlistic.com/p/selenium-practice-form.html
  2. Enter first and last name (textbox).
  3. Select gender (radio button).
  4. Select years of experience (radio button).
  5. Enter date.
  6. Select Profession (Checkbox).
  7. Select Automation tools you are familiar with (multiple checkboxes).
  8. Select Continent (Select box).
  9. Select multiple commands from a multi select box.
  10. If you can handle Upload image then try it or leave this step.
  11. Click on Download file link and handle the download file pop-up (leave it if you are beginner).
  12. Click on Submit button.
  13. Try your own logic and automate it without any help. If you still find it difficult to automate then follow reference links. 
Sample Code:
package com.techlistic.tute;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Keys;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;

public class PracticeFormTest {

    // Main Method is the execution point of any Java Program
    public static void main(String[] args){
        // Initialize Webdriver Object
        System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        // Open URL
        driver.get("https://www.techlistic.com/p/selenium-practice-form.html");
        // Set Chrome window size
        driver.manage().window().setSize(new Dimension(1552, 840));
        // Enter Firstname
        driver.findElement(By.name("firstname")).click();
        driver.findElement(By.name("firstname")).sendKeys("Tom");
        // Set Lastname
        driver.findElement(By.name("lastname")).click();
        driver.findElement(By.name("lastname")).sendKeys("Wood");
        // Select Gender
        driver.findElement(By.id("sex-0")).click();
        // Select Experience
        driver.findElement(By.id("exp-4")).click();
        // Enter Date
        driver.findElement(By.id("datepicker")).click();
        driver.findElement(By.id("datepicker")).sendKeys("16-10-2020");
        // Select Profession
        driver.findElement(By.id("profession-1")).click();
        // Select Automation Tool
        driver.findElement(By.id("tool-2")).click();

        // Select Continent
        driver.findElement(By.id("continents")).click();
        WebElement dropdown = driver.findElement(By.id("continents"));
        dropdown.findElement(By.xpath("//option[. = 'Europe']")).click();

        // Select Command
        WebElement dropdown = driver.findElement(By.id("selenium_commands"));
        dropdown.findElement(By.xpath("//option[. = 'Browser Commands']")).click();

        // Scroll Vertical
        js.executeScript("window.scrollTo(0,675.5555419921875)");

        // Click Submit
        driver.findElement(By.id("submit")).click();
  }
}

You may also like:

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 Selenium Automation Testing Practice

Automate an e-Commerce website with Selenium Webdriver

How to Handle Dynamic Web Table in Selenium WebDriver

Top 50 Selenium Webdriver Interview Questions

Automate Browser Actions and Menu links with Selenium Webdriver

Top 25 Selenium Webdriver Commands for Test Automation