package com.testng1;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class BefforeMethodAfteMethodTest {
WebDriver driver;
@BeforeMethod
public void browser_App_config(){
try{
System.setProperty("webdriver.chrome.driver","C:\\Users\\user\\Desktop\\Driver\\chromedriver.exe");
driver=new ChromeDriver();
driver.get("https://ingenioustechhub.blogspot.com/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
}
catch(Exception e){
e.printStackTrace();
}
}
@Test
public void verifyTitle_tc01(){
try{
String actualTitle=driver.getTitle();
System.out.println("****** actualTitle *****" + actualTitle);
String expectedTitle="ingeniousTechHub";
System.out.println("****** expectedTitle *****" + expectedTitle);
if(actualTitle.equals(expectedTitle)){
System.out.println("***** Title is Matched *****");
}
else{
System.out.println("***** Title is Not Matched *****");
}
System.out.println("************* verifyTitle_tc01 *************");
}
catch(Exception e){
e.printStackTrace();
}
}
@Test
public void verifyHomePageText_tc02(){
try{
String actualText= driver.findElement(By.xpath("//div[@id='header-inner']/div/h1")).getText();
System.out.println("*********** actualText ************" + actualText);
String expctedText="Ingenious TechHub ";
System.out.println("*********** expctedText ************" +expctedText);
if(actualText.equals(expctedText)){
System.out.println("***** Text is Matched *****");
}
else{
System.out.println("***** Text is Not Matched *****");
}
System.out.println("************* verifyHomePageText_tc02 *************");
}
catch(Exception e){
e.printStackTrace();
}
}
@AfterMethod
public void close_BroserApp_config(){
try{
driver.close();
System.out.println("************* BrowserClose & App is logOut *************");
}
catch(Exception e){
e.printStackTrace();
}}
}
No comments:
Post a Comment