Selenium Element Name Locators Practice Form

  • Estimate Completion Time
    not found 30 minutes
  • Difficulty Level:

Test your knowledge and skills in Selenium WebDriver, a popular automation tool for browsers.

In this form, the developer uses the name attribute. Your objective is to automate a website's basic signup form by locating and interacting with components on a web page using a name locator.

Solution

package exercises;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class Exercise2 {

	public static void main(String[] args) {
		// Launch Chrome Browser
		WebDriver driver = new ChromeDriver();

		// Open URL
		driver.get("https://proleed.academy/exercises/selenium/selenium-element-name-locators-practice-form.php");

		// Locate full name by name locator
		WebElement fullname = driver.findElement(By.name("name"));
		fullname.sendKeys("Enter Full Name here");

		// Locate mobile number by name locator
		WebElement mobilenumber = driver.findElement(By.name("mobile"));
		mobilenumber.sendKeys("Enter your mobile number here");

		// Locate email address by name locator
		WebElement emailaddress = driver.findElement(By.name("email"));
		emailaddress.sendKeys("example@gmail.com");

		// Locate password by name locator
		WebElement password = driver.findElement(By.name("password"));
		password.sendKeys("password123");

		// Locate submit button by name locator and click on it
		WebElement submit = driver.findElement(By.name("submit"));
		submit.click();
	}
}
Selenium Automation Practice Exercises - QA Ads Banner

Proleed Academy

Proleed serves / offers professionally designed IT training courses
globally.

Copyright © 2023 - Proleed Academy | All Rights Reserved.