You are on page 1of 2

package com.TestNG.

Basics;

import java.time.Duration;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.datadriven.basics.Reader;

public class FaceBook {

WebDriver driver;

String excelpath="C:\\Users\\Arun\\OneDrive - CodeValue Technologies Private


Limited\\Desktop\\Data.xlsx";

Reader excel;
@BeforeTest
public void browserSetup()
{
driver=new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
driver.get("https://www.facebook.com/");
excel=new Reader(excelpath);

@Test
public void printTitle()
{
System.out.println(driver.getTitle());
}

@Test
public void printUrl()
{
System.out.println(driver.getCurrentUrl());
}

@Test(dataProvider = "data")
public void verifyLogin(String username,String password)
{
driver.findElement(By.id("email")).sendKeys(username);
driver.findElement(By.id("pass")).sendKeys(password);
}

@Test(enabled = false)
public void verifyLogin()
{

driver.findElement(By.id("email")).sendKeys(excel.getSingleExcelData("Sheet1", 0,
0));
driver.findElement(By.id("pass")).sendKeys(excel.getSingleExcelData("Sheet1",
0, 1));
}

@DataProvider(name="data")
public String[][] getData()
{
return excel.getAllExcelData("Sheet1");
}
}

You might also like