how to generate extend report
Code:
WebDriver driver;
static ExtentTest test;
static ExtentReports report;
@BeforeClass
public static void startTest()
{
report = new ExtentReports(System.getProperty("user.dir")+"\\ExtentReportResults.html");
test = report.startTest("OrangeHRM");
System.out.println("befor class");
}
@AfterClass
public static void endTest()
{
report.endTest(test);
report.flush();
}
//Add Candidates
@Given("^Open Url and login with valid data$")
public void open_Url_and_login_with_valid_data() throws Throwable {
setProperties();
driver=login();
}
@When("^click on recruitment and candidates and verify page$")
public void click_on_recruitment_and_candidates_and_verify_page() throws Throwable {
driver.findElement(By.xpath("//*[@id='menu_recruitment_viewRecruitmentModule']/b")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='menu_recruitment_viewCandidates']")).click();
Thread.sleep(2000);
String Expected_msg=driver.findElement(By.xpath("//*[@id='srchCandidates']/div[1]/h1")).getText();
String Actual_msg="Candidates";
Assert.assertEquals(Expected_msg, Actual_msg);
if(Expected_msg.equals(Actual_msg))
{
test.log(LogStatus.PASS, "test pass");
}
else
{
test.log(LogStatus.FAIL, "Test Failed");
}
}
@Then("^click on add buttona and verify page$")
public void click_on_add_buttona_and_verify_page() throws Throwable {
driver.findElement(By.xpath("//*[@id='btnAdd']")).click();
Thread.sleep(2000);
String Expected_msg=driver.findElement(By.xpath("//*[@id='addCandidateHeading']")).getText();
String Actual_msg="Add Candidate";
Assert.assertEquals(Expected_msg, Actual_msg);
}
@Then("^Enter all required Detail$")
public void enter_all_required_Detail() throws Throwable {
driver.findElement(By.xpath("//*[@id='addCandidate_firstName']")).sendKeys("fname");
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='addCandidate_middleName']")).sendKeys("mname");
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='addCandidate_lastName']")).sendKeys("lname");
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='addCandidate_email']")).sendKeys("abc@gmail.com");
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='addCandidate_contactNo']")).sendKeys("4578963217");
Thread.sleep(2000);
}
@Then("^click on Save Button and verify with success mag$")
public void click_on_Save_Button_and_verify_with_success_mag() throws Throwable {
driver.findElement(By.xpath("//*[@id='btnSave']")).click();
String Expected_msg="Successfully Saved"+"\n"+"Close";
String Actual_msg= driver.findElement(By.className("success")).getText();
Assert.assertEquals(Expected_msg, Actual_msg);
}
Comment