Data driven framework in selenium webdriver using excel for login account

package SeleniumLearn;

import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;
import java.util.concurrent.TimeUnit;
import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;

public class DataDrivenFramework {
    public WebDriver driver;
    public String str;
    
        
@Test  // (enabled=false, description="ForLoginFunctionality")
    public void Login() throws Exception {
    driver=new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get("http://www.seleniumlearn.com/user");
    driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS);
    FileInputStream fi=new FileInputStream("C:\\lib\\TestData\\LoginRetesting.xls"); // Here your xls path.
    Workbook w=Workbook.getWorkbook(fi);
    Sheet    s=w.getSheet(0);
    driver.findElement(By.id("edit-name")).sendKeys(s.getCell(0, 1).getContents());
    driver.findElement(By.id("edit-pass")).sendKeys(s.getCell(1, 1).getContents());
    driver.findElement(By.id("edit-submit")).click();
    
    }
 @BeforeTest
      public void beforeTest() {
          driver=new FirefoxDriver();
        /*System.setProperty("webdriver.chrome.driver","C:\\lib\\chromedriver.exe"); //--->chrome browser path
        driver=new ChromeDriver();*/
        
      }

  @AfterTest
  public void afterTest() {
     
  }

}

 

Comments