write a script and verify an login. I need to, by reading a file from xl sheet, first time only give the password and get an error message, second time give the email only and get an error message and third time give both email and correct password and get "Signed in".
package webdriver;
import com.thoughtworks.selenium.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.FileInputStream;
import java.util.concurrent.TimeUnit;
import jxl.Sheet;
import jxl.Workbook;
import org.openqa.selenium.By;
public class emailVerify {
private WebDriver driver;
@BeforeClass
public void startUp() throws Exception {
driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES);
}
@Test
public void testemailVerify() throws Exception{
driver.get("http://www.xxxx.com");
driver.findElement(By.id("id=signin-text")).click();
Thread.sleep(5000);
FileInputStream fis=new FileInputStream("C:\\Selenium\\Ev.xls");
Workbook wb=Workbook.getWorkbook(fis);
Sheet s= wb.getSheet(0);
//try
//{
for(int i=1; i {
String s1=s.getCell(0,i).getContents();
driver.findElement(By.id("xxxxxx")).sendKeys(s1);
driver.findElement(By.linkText("SIGN IN")).click();
System.out.println("Please enter a valid email address!");
String s2=s.getCell(1,i).getContents();
driver.findElement(By.id("yyyyyy")).sendKeys(s2);
driver.findElement(By.linkText("SIGN IN")).click();
System.out.println("A valid password id required!");
String s3=s.getCell(4,i).getContents();
driver.findElement(By.id("yyyyyyy")).sendKeys(s2);
driver.findElement(By.id("xxxxxx")).sendKeys(s3);
driver.findElement(By.linkText("SIGN IN")).click();
System.out.println("Signed in");
}
}
@AfterClass
public void tearDown() throws Exception{
driver.quit();
}
}