ATU Reporter

Add Jar to your project

 

Step : 1

Two important classes which we will be using

  • ATUReportsListener – A TestNG Listener
  • ConfigurationListener – A TestNG Listener
  • MethodListener – A TestNG Listener
  • ATUReports – Used for logging the report data

Step : 2

atu.properties file

#change results directory
atu.reports.dir=C:\\Users\\Youtility\\Desktop\\WebApp_AutomationCode\\TCS\\

#change header text
atu.proj.header.text=AUT Reports Header

#add project/client logo, the image is copied to “HTML_Design_Files/IMG” directory
atu.proj.header.logo=H:\\php\\htdocs\\eresto\\user\\images\\logo1.jpg

#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 : 3 – Complete program.

package main.seTests;

import java.awt.AWTException;
import java.io.IOException;
import java.sql.SQLException;

import org.junit.AfterClass;
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 AUTreports {
{ System.setProperty(“atu.reporter.config”, “C:\\Users\\Youtility\\Desktop\\WebApp_AutomationCode\\TCS\\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 + “/”);
driver.manage().window().maximize();
// ATU Reports
ATUReports.setWebDriver(driver);
ATUReports.indexPageDescription = “My CSR 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, InterruptedException {

ATUReports.add(“INfo Step”, LogAs.INFO, new CaptureScreen(ScreenshotOf.BROWSER_PAGE));
ATUReports.add(“Pass Step”, LogAs.PASSED, new CaptureScreen(ScreenshotOf.DESKTOP));
Thread.sleep(2500);
WebElement element = driver.findElement(By.xpath(“//input[@id=’lst-ib’]”));
ATUReports.add(“Warning Step”, LogAs.WARNING,new CaptureScreen(element));
ATUReports.add(“Fail step”, LogAs.FAILED, new CaptureScreen(ScreenshotOf.DESKTOP));
}

@AfterClass
public void tearDown() throws Exception {
driver.quit();
}
}

Step : 4

testNG.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”&gt;
<suite guice-stage=”DEVELOPMENT” name=”Default suite”>
<test verbose=”2″ name=”Default test”>
<classes>
<class name=”main.seTests.AUTreports”/>
</classes>
</test> <!– Default 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> <!– Default suite –>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s