Generation

code to explanationMon, 13 Feb 2023

import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.Assert; import org.testng.annotations.Test; public class LoginAutomation { @Test public void login() { System.setProperty("webdriver.chrome.driver", "path of driver"); WebDriver driver=new ChromeDriver(); driver.manage().window().maximize(); driver.get("https://www.browserstack.com/users/sign_in"); WebElement username=driver.findElement(By.id("user_email_Login")); WebElement password=driver.findElement(By.id("user_password")); WebElement login=driver.findElement(By.name("commit")); username.sendKeys("abc@gmail.com");

Here, we’ll first open the website using the 'get' method and then will find the username, password, and login button using the ‘findElement’ method.

Want to kickstart your project?Use the new AI Studio to create your code