Reporting with ATU Plugin

Reporting is always a challenge in automaiton, in previous post we have seen reporting with ReportNG, XSLT, Extent reporting pluging. In this post we see another free open source tool called ATU Reporter.

ATU Reporter is free open source plugin/utility for Selenum. This will be a TestNG listener for generating customized graphical reports. Following reports can be generated by this listener. 
Line Charts 
Bar Charts 
Pie Charts 

Please go to this blog for more details :

Step1 : Download ATU Reporter  5.1.1 from below drive.

https://drive.google.com/a/datarpm.com/folderview?id=0B7rZvkq9tkwPMkJlUjJGTkJjOTA&usp=sharing#

Step 2 : Go to eclipse and create a new Project as Reports and package as 
com.test.AUTReporting;

Step3 : After downloading unzip and add the ATU reporter jar in eclipse project.







Step 4 : In Un-zipped file we should be able to locate atu.properties file, copy this and paste to your project 



Step 5 : What;s there in atu.properties file, its configuration file please change where ever necessary 

#change results directory
atu.reports.dir=D://ATU Reporter
#change header text
atu.proj.header.text=My Proj Reports
#add project/client logo, the image is copied to "HTML_Design_Files/IMG" directory
atu.proj.header.logo=
#specify your project description
atu.proj.description=MyProject Testing Reports
#An option for the user to set whether screenshots should be taken or not regardless of what the user has logged in the script.
#Setting false for taking screenshots results in faster execution time. This option is best suitable when you use HtmlUnitDriver
atu.reports.takescreenshot=true
#User has the option to choose whether configuration reports should be generated or not
#Available options: true, false
atu.reports.configurationreports=true
#generate excel reports - the first preview of excel reports - with noticeable limitations
#Available options: true, false
atu.reports.excel=false
#when a user logs the step as failed (using LogAs parameter), you can continue execution of the remaining steps using this property
#Available options: true, false
atu.reports.continueExecutionAfterStepFailed = true
#Record test execution
#testmethod: recored execution for every single test method in its own movie file, not yet implemented
#suite: record execution of complete suite in a single movie file
#Available options: suite, none
atu.reports.recordExecution=suite
#Maximum number of runs to generate, not yet implemented
atu.reports.setMaxRuns = 100
#generate pdf reports, not yet implemented
atu.reports.pdf=false
Step 6 : Create a simple testng class file as ReporterGoogleTest by adding all ATU reporter methods.
Below lines of code will call the ATUReports Listeners and also path for the atu.properties files
@Listeners({ ATUReportsListener.class, ConfigurationListener.class,
MethodListener.class })
public class ReporterGoogleTest {
{
System.setProperty("atu.reporter.config", "/yourpath/atu.properties");
}
This file also contain two test methods as
@Test
public void GoogleTooltip() throws Exception, SQLException {
Actions ToolTip1 = new Actions(driver);
WebElement googleLogo = driver.findElement(By
.xpath("//div[@id='hplogo']"));
ToolTip1.clickAndHold(googleLogo).perform();
String ToolTipText = googleLogo.getAttribute("title");
Assert.assertEquals(ToolTipText, "Google");
System.out.println("Tooltip value is: " + ToolTipText);
}
// ATU Reports Method
@Test
public void testNewLogs() throws AWTException, IOException {
ATUReports.add("INfo Step", LogAs.INFO, new CaptureScreen(
ScreenshotOf.BROWSER_PAGE));
ATUReports.add("Pass Step", LogAs.PASSED, new CaptureScreen(
ScreenshotOf.DESKTOP));
WebElement element = driver
.findElement(By.xpath("/html/body/div/h1/a"));
ATUReports.add("Warning Step", LogAs.WARNING,
new CaptureScreen(element));
ATUReports.add("Fail step", LogAs.FAILED, new CaptureScreen(
ScreenshotOf.DESKTOP));
}
Final file would look like this :
package com.test.AUTReporting;
import java.awt.AWTException;
import java.io.IOException;
import java.sql.SQLException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import atu.testng.reports.ATUReports;
import atu.testng.reports.listeners.ATUReportsListener;
import atu.testng.reports.listeners.ConfigurationListener;
import atu.testng.reports.listeners.MethodListener;
import atu.testng.reports.logging.LogAs;
import atu.testng.selenium.reports.CaptureScreen;
import atu.testng.selenium.reports.CaptureScreen.ScreenshotOf;
@Listeners({ ATUReportsListener.class, ConfigurationListener.class,
MethodListener.class })
public class ReporterGoogleTest {
{
System.setProperty("atu.reporter.config", "/Users/gururaj/workspace/Reports/atu.properties");
}
private WebDriver driver;
private String baseUrl;
@BeforeMethod
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://www.google.co.in";
driver.get(baseUrl + "/");
// ATU Reports
ATUReports.setWebDriver(driver);
ATUReports.indexPageDescription = "Test Project";
}
@Test
public void GoogleTooltip() throws Exception, SQLException {
Actions ToolTip1 = new Actions(driver);
WebElement googleLogo = driver.findElement(By
.xpath("//div[@id='hplogo']"));
ToolTip1.clickAndHold(googleLogo).perform();
String ToolTipText = googleLogo.getAttribute("title");
Assert.assertEquals(ToolTipText, "Google");
System.out.println("Tooltip value is: " + ToolTipText);
}
// ATU Reports Method
@Test
public void testNewLogs() throws AWTException, IOException {
ATUReports.add("INfo Step", LogAs.INFO, new CaptureScreen(
ScreenshotOf.BROWSER_PAGE));
ATUReports.add("Pass Step", LogAs.PASSED, new CaptureScreen(
ScreenshotOf.DESKTOP));
WebElement element = driver
.findElement(By.xpath("/html/body/div/h1/a"));
ATUReports.add("Warning Step", LogAs.WARNING,
new CaptureScreen(element));
ATUReports.add("Fail step", LogAs.FAILED, new CaptureScreen(
ScreenshotOf.DESKTOP));
}
@AfterMethod
public void tearDown() throws Exception {
driver.quit();
}
}
Step 7 : Create Tesng.xml file to call the ATU Reporter listener and the testng class
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="false">
<test name="Test">
<classes>
<class name="com.test.AUTReporting.ReporterGoogleTest"/>
</classes>
</test>
<listeners>
<listener class-name="atu.testng.reports.listeners.ATUReportsListener"></listener>
<listener class-name="atu.testng.reports.listeners.ConfigurationListener"></listener>
<listener class-name="atu.testng.reports.listeners.MethodListener"></listener>
</listeners>
</suite>
view raw 4.testng.xml hosted with ❤ by GitHub

Step 8  : Right click and run the script as TestNG Suite

On the console should display output as :




Refresh the project as this and go to folder ATU Reporter and open index.html















Thanks 


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.