how to generate extent report in java?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gosai jahnvi
    New Member
    • Apr 2019
    • 22

    how to generate extent report in java?

    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);
    	}
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    gosai jahnvi:

    Why do you expect us to decipher your code and answer a question with so little information?

    This is a very simple and basic question - did you do a google search? The following returned About 8,060,000 results in 0.97 seconds :(


    So what specifically is it that you need?
    What specifically are the issues you are encountering?
    What specifically have you done in an attempt to solve those challenges?

    Your questions really read like homework/course work questions and those are not allowed on this site.
    Last edited by zmbd; Jun 27 '19, 04:59 AM.

    Comment

    Working...