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.
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();
}
}
Copyright © 2023 - Proleed Academy | All Rights Reserved.