Extent report gives you online HTML Report with screenshot.
You need to have Extent report jar with you ,It also need freemarker jar, below is Jar URL,
https://jar-download.com/? detail_search=g%3A%22com. relevantcodes%22+AND+a%3A% 22extentreports%22&search_ type=av&a=extentreports
https://jar-download.com/?
Below is code for extent report,
public class HomeVerification extends BaseClass {
//extent report initializatiion
ExtentReports report;
ExtentTest test;
@Before
public void setBrowser() {
//u need to write broser launch selenium code
startBrowser("chrome");
System.out.println("browser launchead");
}
@Test
public void login() throws InterruptedException, IOException {
//report path
report = new ExtentReports("C:\\Users\\ ylondhe\\reports\\ automationreport.html", true);
//report = new ExtentReports("D:\\ automationreport.html", true);
test = report.startTest("Verify application Home screen");
driver.get("TestingURL");
test.log(LogStatus.INFO, "URL Launched started");
String actualTitle = driver.getTitle();
test.log(LogStatus.INFO, "page title is " + actualTitle );
//Thread.sleep(30000);
(new WebDriverWait(driver, 30))
.until(ExpectedConditions.elem entToBeClickable(By.xpath("//* [@id='headertext']")));
List<WebElement> list = driver.findElements(By.xpath(" //*[@id='navitemlist']/li[1]/ a/span1"));
// Assert.assertTrue("Text not found!", list.size() > 0);
System.out.println(list.size() );
if(list.size()>0){
test.log(LogStatus.PASS, "Element is Present");
System.out.println("element present");
}
else{
//fail scenario, capture image code
File scrFile = ((TakesScreenshot) driver).getScreenshotAs( OutputType.FILE);
FileUtils.copyFile(scrFile,
String image = test
test.log(LogStatus.FAIL, "verify logo of the application", image);
}
Thread.sleep(5000);
}
@After
public void closeDriver() {
driver.close();
report.endTest(test);
report.flush();
}
}
No comments:
Post a Comment