This test opens a login page, types 'testUser' into the username field and 'pass123' into the password field, then prints a success message.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class TypingTextTest {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
WebDriver driver = new ChromeDriver();
try {
driver.get("https://example.com/login");
WebElement usernameField = driver.findElement(By.id("username"));
usernameField.sendKeys("testUser");
WebElement passwordField = driver.findElement(By.id("password"));
passwordField.sendKeys("pass123");
System.out.println("Text typed successfully.");
} finally {
driver.quit();
}
}
}