Wednesday, June 4, 2014

Use of @BeforeClass and @AfterClass

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class Jcrew {
WebDriver driver ;
@Test
public void f() throws Exception {
driver.get("https://www.jcrew.com/index.jsp" );
driver.findElement(By.id("welcomeMatUsLink")).click();
driver.findElement(By.id("globalHeaderSignIn")).click();
Thread.sleep(3000);
driver.findElement(By.xpath("//a[@class='button-general button-nosubmit']")).click();
driver.findElement(By.id("lastName")).sendKeys("mahesh");
driver.findElement(By.id("emailAdd")).sendKeys("cnu.don1@gmail.com");
driver.findElement(By.id("emailAddConf")).sendKeys("cnu.don1@gmail.com");
driver.findElement(By.id("passWord")).sendKeys("mahesh123");
driver.findElement(By.id("passWordConf")).sendKeys("mahesh123");
driver.findElement(By.id("zipCode")).sendKeys("502109");
driver.findElement(By.id("zipCode")).sendKeys("502109");
driver.findElement(By.id("homePhone")).sendKeys("9052404371");
WebElement dd = driver.findElement(By.id("country")) ;
Select d = new Select (dd) ;
d.selectByIndex(3);
String txt = driver.findElement(By.id("erorMsg")).getText() ;
String pnt = "Please enter first name." ;
Thread.sleep(15000);

driver.findElement(By.xpath("//input[@name='createAccountAndStartShopping']")).click();
txt.equals(pnt) ;
}
@BeforeClass
public void beforeClass() {
driver = new FirefoxDriver() ;
//driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

}
@AfterClass
public void afterClass() {
// driver.quit();
}
}

No comments:

Post a Comment