Oracle Application Testing Suite- Custom HTML Report
Today we will see how to generate custom html report in OATS (Oracle Application Testing Suite) . Oracle ATS provides default result report which has all logs including each step performed by script which is not so pleasing to show to management.
That calls to create Custom Html Report where you can show what is needed as per the Testing point of view.
Extent report gives you facility to represent Test Steps Pass/Fail in systematically with Good Interface and Graphs
Report generated by Extent report API:
To Integrate with OATS we require below Jars
For this we require below jars and components
- extentreports-2.40.2.jar
- sqlite-jdbc-3.23.1.jar
- jsoup-1.11.3.jar
- freemarker-2.3.20.jar
These jars can be downloaded from here – DOWNLOAD EXTENT API JARS
To demonstrate clearly we will simple Use case:
Step1: Launch Google Search Engine
Step2: Search Wikipedia.com
Step3: Open www.Wikipedia.com Link
Step4: Search Software Testing Page
Step5: Verify Title as Software Testing
Step6: Close Browser
Lets begin creating new script..
- Navigate to File–>New Script
- Select type as Web
- Click finish
- Enter Write Extent Report code to generate report, find the code below(Detail Explanation given in comment section of script)
Important Code Explanation:
Declare two variable:
ExtentReports extent; --> Instance of Extent Report Variable
ExtentTest logger; --> Instance of Extent Test Variable
then in Intitialise method ()
extent = new ExtentReports("C:\\OracleATS\\OFT\\Demo\\TC_CustomeReporting\\OATSReports\\Demo_Report.html", false);
Define path where you want to store Extent Report
extent.loadConfig(new File ("C:\\OracleATS\\OFT\\SCM_AUTOMATION\\Results\\extent-config.xml"));
Here you will define configuration of your Extent report like theme, DB details etch
logger.log(LogStatus.PASS, "Launch Google Search Engine");
above line of code will write HTML reoport as Pass
logger.log(LogStatus.FAIL, "Launch Google Search Engine");
below line of code will write HTML report as Fail
thats it , try out complete code below in your OATS tool
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;
import oracle.oats.scripting.modules.utilities.api.xml.*;
import oracle.oats.scripting.modules.utilities.api.file.*;
import oracle.oats.scripting.modules.webdom.api.*;
public class script extends IteratingVUserScript {
@ScriptService oracle.oats.scripting.modules.utilities.api.UtilitiesService utilities;
@ScriptService oracle.oats.scripting.modules.browser.api.BrowserService browser;
@ScriptService oracle.oats.scripting.modules.functionalTest.api.FunctionalTestService ft;
@ScriptService oracle.oats.scripting.modules.webdom.api.WebDomService web;
ExtentReports extent;
ExtentTest logger;
public void initialize() throws Exception {
/*Give report path where you want to store reports
* true indicates file gets override
* flase file will not get override, and each execution history comes to report
*/
extent = new ExtentReports("C:\\OracleATS\\OFT\\Demo\\TC_CustomeReporting\\OATSReports\\Demo_Report.html", false);
/*
* Provide config file location, based on exten-config.xml extent report sets some prefernces like theme, encoding, date formats
*/
extent.loadConfig(new File ("C:\\OracleATS\\OFT\\SCM_AUTOMATION\\Results\\extent-config.xml"));
/*
* Provide test case name, author and category
*/
logger = extent.startTest(this.getScriptPackage().getScriptName()+"_"+getDateTime(),"Description");
logger.assignAuthor("Basavaraj N W");
logger.assignCategory("AIB");
browser.launch();
}
/**
* Add code to be executed each iteration for this virtual user.
*/
public void run() throws Exception {
//Step1: Launch Google Search Engine
beginStep("Launch Google Search Engine", 0);
{
web.window(4, "{{obj.demo.web_window_0_1}}").navigate("http://www.google.com/");
web.window(5, "{{obj.demo.web_window_0_2}}").waitForPage(60);
logger.log(LogStatus.PASS, "Launch Google Search Engine");
}
endStep();
//Step2: Search Wikipedia.com
beginStep("Search Wikipedia.com", 0);
{
web.textBox(6, "{{obj.demo.web_input_text_lst_ib}}").click();
web.textBox(72, "{{obj.demo.web_input_text_lst_ib}}").setText("Software Testing");
web.textBox(73, "{{obj.demo.web_input_text_lst_ib}}").pressEnter();
think(3);
logger.log(LogStatus.PASS, "Search Software Testing");
}
endStep();
//Step3: Open www.Wikipedia.com Link
beginStep("Open Software Testing Link", 0);
{
web.link(75, "{{obj.demo.web_a_Software_testing___Wikipe_2}}").click();
think(3);
logger.log(LogStatus.PASS, "Open Software Testing page in wikipedia");
}
endStep();
//Step4: Verify Title as Software Testing
beginStep("Verify Title as Software Testing Page", 0);
{
String strValue=web.element(61, "{{obj.demo.web_h1_Software_testing}}").getAttribute("text");
if(strValue.equalsIgnoreCase("Software Testing")){
logger.log(LogStatus.PASS, "Software Testing text is validated succesfully");
}else{
logger.log(LogStatus.FAIL, "Software Testing text is validated succesfully");
}
}
endStep();
//Step5: Close Browser
beginStep("[1] Close Browser", 0);
{
browser.close();
logger.log(LogStatus.PASS, "Browser closed");
}
endStep();
}
public void finish() throws Exception {
extent.endTest(logger);
extent.flush();
extent.close();
}
private String getDateTime() {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
return dateFormat.format(date);
}
}