webdriver, dataprovider, annotations, testng, framework

import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class yahoo_login_dp
{

    public FirefoxDriver fd;
   
    @DataProvider(name="p1")
    public String[][] y()
    {
        return new String[][]{ {"xxxxxxxx","xxxxxxx"},{"xxxxxxxxxx","xxxxxx"},{"mindqtest1"," "}};
    }   
   
    @BeforeClass
    public void BeforeClass()
    {
     fd=new FirefoxDriver();
   
    }   
   
    @Test(dataProvider="p1")
    public void fn_login(String uid,String pwd) throws Exception
    {
        fd.get("http://www.yahoomail.com");
        fd.findElement(By.name("login")).sendKeys(uid);
        fd.findElement(By.name("passwd")).sendKeys(pwd);
        fd.findElement(By.name(".save")).click();
        Thread.sleep(5000);
        try
        {
          if(fd.findElement(By.linkText("Sign Out")).isDisplayed())
          {
           System.out.println("Login is success");
           fd.findElement(By.linkText("Sign Out")).click();
          }
         }
         catch(Exception e)
         {
          System.out.println("Login is failed");
         }
      }
   

   @AfterClass
   public void AfterClass()
   {
       fd.close();
   }
   }

Comments