Sunday, 23 November 2014

How to Login in using selenium

package com.SeleniumGuru;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Login {
WebDriver driver = new FirefoxDriver();
@BeforeTest
public void launchapp() {
// Puts a Implicit wait, Will wait for 10 seconds before throwing
// exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// Launch website
driver.navigate().to("https://mail.google.com/mail/");
driver.manage().window().maximize();
}
@AfterTest
public void terminatetest() {
driver.quit();
}
@Test
public void Login() {
try {
driver.findElement(By.name("Email")).sendKeys("test@gmail.com");
driver.findElement(By.name("Passwd")).sendKeys("0judyqU2589r");
driver.findElement(By.name("signIn")).click();
} catch (Exception e) {
System.out.println(e);
}
}
}




login3

No comments:

Post a Comment