Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package goo.stqa.sgmail;
- import org.apache.poi.xssf.usermodel.XSSFSheet;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.openqa.selenium.By;
- import org.openqa.selenium.NoAlertPresentException;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.testng.annotations.AfterMethod;
- import org.testng.annotations.BeforeMethod;
- import org.testng.annotations.Test;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.util.concurrent.TimeUnit;
- public class RegistratFormTest {
- FirefoxDriver wd;
- public static boolean isAlertPresent(FirefoxDriver wd) {
- try {
- wd.switchTo().alert();
- return true;
- } catch (NoAlertPresentException e) {
- return false;
- }
- }
- @BeforeMethod
- public void setUp() throws Exception {
- wd = new FirefoxDriver();
- wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
- }
- @Test
- public void logTest() throws Exception {
- wd.get("https://gmail.com/");
- wd.findElement(By.linkText("Create account")).click();
- try {
- File file = new File("C:\\Reposit\\gettingtest\\UserData.xlsx");
- FileInputStream iFile = new FileInputStream(file);
- XSSFWorkbook wb = new XSSFWorkbook(iFile);
- XSSFSheet sheet = wb.getSheet("Sheet1");
- int rowCount = sheet.getLastRowNum();
- //System.out.println("the no of rows are : " + rowCount);
- for (int row = 1; row <= rowCount; row++) {
- String Username = sheet.getRow(row).getCell(0).getStringCellValue();
- String LastName = sheet.getRow(row).getCell(1).getStringCellValue();
- String GmailAddress = sheet.getRow(row).getCell(2).getStringCellValue();
- String Password = sheet.getRow(row).getCell(3).getStringCellValue();
- wd.findElement(By.id("FirstName")).sendKeys(Username);
- wd.findElement(By.id("LastName")).sendKeys(LastName);
- wd.findElement(By.id("GmailAddress")).sendKeys(GmailAddress);
- wd.findElement(By.id("Passwd")).sendKeys(Password);
- wd.findElement(By.id("PasswdAgain")).sendKeys(Password);
- wd.findElement(By.id("birthday-placeholder")).click();
- wd.findElement(By.id("BirthDay")).clear();
- wd.findElement(By.id("BirthDay")).sendKeys("12");
- /*wd.findElement(By.xpath("//label [@id='day-label']/span")).click();
- wd.findElement(By.id("BirthDay")).sendKeys("20");*/
- wd.findElement(By.xpath(".//*[@id='BirthYear']")).click();
- wd.findElement(By.xpath(".//*[@id='BirthYear']")).sendKeys("2010");
- }
- iFile.close();
- //wd.findElement(By.xpath("//label[@id='month-label']/span/div/div")).click();
- //wd.findElement(By.xpath("//label[@id='month-label']/span/div/div[@aria-posinset='5']")).click();
- //WebElement monthSelect = wd.findElement(By.id("BirthMonth"));
- //wd.findElement(By.xpath(".//*[@id=':0']")).sendKeys("September");
- //wd.findElement(By.id(".//*[@id='BirthMonth']/div[1]")).click();
- // WebElement divElement = wd.findElement(By.xpath("//span [@id='BirthMonth']/div"));
- //divElement.findElement(By.xpath("div[1]")).click();
- wd.findElement(By.xpath("//*[@id=\"BirthMonth\"]/div")).click();
- wd.findElement(By.xpath("//*[@id=\":6\"]/div")).click();
- wd.findElement(By.xpath("./*//*[@id='Gender']/div")).click();
- wd.findElement(By.xpath("//div[@id=':f']//div[.='Male']")).click();
- wd.findElement(By.id("submitbutton")).click();
- wd.findElement(By.id("iagreebutton")).click();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- @AfterMethod
- public void tearDown() {
- wd.quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement