WebDriver driver = null;
@BeforeSuite
public void suiteSetup() {
System.setProperty("webdriver.chrome.driver", "D:\\drivers\\chromedriver.exe");
driver = new ChromeDriver();
}
//Simply create some blank annotations over here for validation purpose
@BeforeTest
public void testSetup() {
}
@BeforeMethod
public void methodSetup() {
}
@Test
public void testMethod1() throws IOException {
FileInputStream file = new FileInputStream("C:\\Users\\Desktop\\Leave_Details.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(file);// .xslx file
HSSFWorkbook wb = new HSSFWorkbook(file);- .xsl file
XSSFSheet sh = wb.getSheet("Sheet1");
HSSFSheet sh = wb.getSheet("Sheet1");// Sheet1 need to be replaced with actual tab name
System.out.println(sh.getRow(0).getCell(0).getStringCellValue()); // Gives the data. need to update the row and column numbers accordingly
driver.get("url");
//Get the title of the application
String strTitle = driver.getTitle();
System.out.println("Title of the page:"+strTitle);
//No of elements
List<WebElement> listElements = driver.findElements(By.xpath("")); // Use findelemet'S' not findelement
System.out.println(listElements.size());
}
@Parameters ({"Type","Name"}) // Add name of parameters added in testng.xml and give name over here and do the same naming in method
@Test
public void testMethod2(String strType, String strName) {
System.out.println(strType); //Gives the parameter value specified in testng.xml
}
@AfterTest
public void testTearDown() {
}
@AfterMethod
public void methodTearDown() {
}
@AfterSuite
public void suiteTearDown() {
driver.close();
}