Selenium Element ID 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 id attribute. Your objective is to automate a website's login form by locating and interacting with components on a web page using an ID 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 Exercise1 {

	public static void main(String[] args) {

		// Launch Chrome Browser
		WebDriver driver = new ChromeDriver();

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

		driver.manage().window().maximize();

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

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

		// Locate submit button by ID locator and click on it
		WebElement submit = driver.findElement(By.id("login"));
		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.