NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io



//Variables to be updated in Constants file.

public static String pathOfScreenshot="/Users/v4/Documents/Atoms/Report/Screenshot/";

public static String capturedScreenshot=null;

public static ExtentReports extentReporter=null;

public static ExtentTest extentTest=null;


public static String pathOfReport = "/Users/v4/Documents/Atoms/Report/htmlReport/“;

public static String logsPath= "/Users/v4/Documents/Atoms/Report/Logs/";


public static String extentReportConfigFile ="/Users/v4/Documents/Atoms/SupportingFiles/extentrepotconfig.xml”;





Start Script:-

//Mandatory initialisation before start of reading test data:-

/****** Extent Report Initialization ********/

logger.info("Configurin extent Report");
constants.extentReporter = new ExtentReports(constants.pathOfReport +
(new SimpleDateFormat("yyyyMMddHHmm'.html'").format(new Date())),
true,
DisplayOrder.OLDEST_FIRST);

//Adding Environmental Variables
constants.extentReporter.addSystemInfo("Environment", constants.environment);
constants.extentReporter.addSystemInfo("Test Data","<a href="+constants.pathToTestData+"><span class='label info'>Test Data</span></a>" );
constants.extentReporter.addSystemInfo("Mapping Sheet ", "<a href="+constants.pathToMappingSheet+"><span class='label info'>Mapping Sheet</span></a>");
//

//Configuration done for extentReport -> 2.0.1 version
constants.extentReporter.config().insertCustomStyles("/Users/v4/Documents/Atoms/extentrepotconfig.xml");

//Configuring the HTML report.
constants.extentReporter.loadConfig(new File(constants.extentReportConfigFile));

Mandatory to call when execution is completed to write all the data into report:-
public void shutdown()

{

constants.extentReporter.flush();

constants.extentReporter.close();

}





Reading TestData:-



Step 1:- Once after testData is read we call the below line of code



// Each test will be one JourneyID
constants.extentTest = constants.extentReporter.startTest(testDataValues.get("journeyid") ,testDataValues.get("journeyid"));// we can take two arguements and see what happens
// Statement will throw nullPointerException incase if its invoked any time before startTest
constants.extentTest.assignAuthor(System.getProperty("user.name")); //Gets the system user name.



Step 2:-Method invoked when particular row or use case is executed:-

constants.extentReporter.endTest(constants.extentTest);



Step 3:In report we have categorisation called as Parent category and Child category:-

Parent category is platform and child category is mapped at journeyID level.

//Assigning category. Each platform is marked as one category.Called at our platform controller.
constants.extentTest.assignCategory("Chrome Browser","Chrome");



Step4: Action methods are invoked. Each of method returns a string either is Passed (returned in try block) and Failed(Exception Block). . Enhacement is in progress to retune the error code, based on error code, report gets generated.



String statusOfMethod = (String) actionMethods[i].invoke(executekeywords);
if(statusOfMethod!=null) //This line goes applicable for optional functions.
{
generateReport(statusOfMethod);
}



Step 5: Function to generate report:



/************** Report Generation ****************/

public static void generateReport(String statusFlag){

if(statusFlag.contains("Passed")){

StringBuffer s1= new StringBuffer();
// s1.append(statusFlag);
// s1.append(expectedResult);
logger.debug("Status marked in Pass block : " + s1 );
constants.extentTest.log(LogStatus.PASS, useCase , "<font size="+3+" color='#7CFC00'>"+statusFlag +"</font>"+ " <br />" +expectedResult);

}else if(statusFlag.contains("Fail"))
{
//String q= statusFlag;
String screenshotPath= reusuableFunctions.captureScreenshot();
String imageOfFailedScenario = constants.extentTest.addScreenCapture(screenshotPath);
logger.debug(imageOfFailedScenario);
logger.debug("Status marked in Fail block : " + statusFlag);
constants.extentTest.log(LogStatus.FAIL,
useCase,
"<span title='"+constants.statusFlag+"'><a href='"+constants.logsPath+"/automationFramework.log'><font size="+3+" color='#DC143C'>FAILED</font></a></span>"+
imageOfFailedScenario);



}else{

logger.debug("skipped" + statusFlag);
constants.extentTest.log(LogStatus.SKIP, useCase, statusFlag);
}

}





Sample Action retuning the data that we need:-




//inputTextMandatory
public static String inputText(){

logger.info("inputText invoked with locator Type =" + locatorType + " | and value = " +locatorValue);


try {
// WebDriver wait.

if (testData != null) {

testData=checkIfKeyExist();
logger.info("Current TestData vlaue is.."+testData);

constants.wait = new WebDriverWait(constants.driver, 30);
constants.wait.until(ExpectedConditions.elementToBeClickable(getLocator(locatorType, locatorValue)))
.clear();

WebElement e = constants.driver.findElement(getLocator(locatorType, locatorValue));
e.sendKeys(testData);

if (e.getAttribute("value").equals("") || e.getAttribute("value").isEmpty()) {
logger.error("inputText : Text is not entered");
constants.hasFailure = true;
constants.statusFlag = "Failed :Text not entered";

}

else
{
constants.statusFlag = "Passed : input text entered -" + e.getAttribute("value");
}

} else {
logger.error("Test data is missing");
constants.hasFailure = true;
constants.statusFlag = "Failed: TestData missing";

}

}catch (Exception E){

E.printStackTrace();
logger.error("Unable to locate element " +E.getCause());
constants.hasFailure=true;
constants.statusFlag="Failed " + E.getMessage();
}

return constants.statusFlag;


}





     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.