Skip to content

Commit 677db1b

Browse files
committed
extent
1 parent 2b3df2a commit 677db1b

File tree

102 files changed

+3957
-1186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+3957
-1186
lines changed

.classpath

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
</classpathentry>
1414
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
1515
<attributes>
16+
<attribute name="test" value="true"/>
1617
<attribute name="optional" value="true"/>
1718
<attribute name="maven.pomderived" value="true"/>
18-
<attribute name="test" value="true"/>
1919
</attributes>
2020
</classpathentry>
2121
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
2222
<attributes>
23-
<attribute name="maven.pomderived" value="true"/>
2423
<attribute name="test" value="true"/>
24+
<attribute name="maven.pomderived" value="true"/>
2525
</attributes>
2626
</classpathentry>
27-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
27+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.8.0_51">
2828
<attributes>
2929
<attribute name="maven.pomderived" value="true"/>
3030
</attributes>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.w2a.Utilities;
2+
3+
import java.io.File;
4+
5+
import com.relevantcodes.extentreports.ExtentReports;
6+
7+
public class ExtentManager {
8+
9+
private static ExtentReports extent;
10+
11+
public static ExtentReports getInstance() {
12+
if (extent == null) {
13+
extent = new ExtentReports(System.getProperty("user.dir)"+"\\target\\surefire-reports\\html\\extent.html"));
14+
extent.loadConfig(new File(System.getProperty("user.dir)"+"\\src\\test\\resources\\extentconfig\\ReportsConfig.xml")));
15+
}
16+
return extent;
17+
}
18+
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.w2a.Utilities;
2+
import java.io.File;
3+
import java.io.IOException;
4+
import java.util.Date;
5+
6+
import org.apache.commons.io.FileUtils;
7+
import org.openqa.selenium.OutputType;
8+
import org.openqa.selenium.TakesScreenshot;
9+
10+
11+
import com.w2a.base.TestBase;
12+
13+
public class TestUtil extends TestBase{
14+
15+
public static String screenshotPath;
16+
public static String screenshotName;
17+
18+
public static void captureScreenshot() throws IOException {
19+
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
20+
Date d = new Date();
21+
screenshotName = d.toString().replaceAll(":", "_").replaceAll(" ", "_");
22+
FileUtils.copyFile(scrFile, new File(System.getProperty("user.dir")+"\\target\\surefire-reports\\html\\"+screenshotName));
23+
24+
25+
}
26+
27+
}

src/test/java/com/w2a/base/TestBase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
import org.testng.annotations.BeforeSuite;
1818
import org.testng.log4testng.Logger;
1919

20+
import com.relevantcodes.extentreports.ExtentReports;
21+
import com.relevantcodes.extentreports.ExtentTest;
2022
import com.w2a.Utilities.ExcelReader;
23+
import com.w2a.Utilities.ExtentManager;
2124

2225
public class TestBase {
2326

@@ -34,6 +37,8 @@ public class TestBase {
3437
public static ExcelReader excel = new ExcelReader(
3538
System.getProperty("user.dir") + "\\src\\test\\resources\\excel\\testdata.xlsx");
3639
public static WebDriverWait wait;
40+
public ExtentReports rep = ExtentManager.getInstance();
41+
public static ExtentTest test;
3742

3843
@BeforeSuite
3944
public void setUp() {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.w2a.listeners;
2+
3+
import java.io.IOException;
4+
5+
import org.testng.ITestContext;
6+
import org.testng.ITestListener;
7+
import org.testng.ITestResult;
8+
import org.testng.Reporter;
9+
10+
import com.relevantcodes.extentreports.LogStatus;
11+
import com.w2a.Utilities.TestUtil;
12+
import com.w2a.base.TestBase;
13+
14+
public class CustomListeners implements ITestListener {
15+
16+
public void onTestStart(ITestResult result) {
17+
// TODO Auto-generated method stub
18+
19+
}
20+
21+
public void onTestSuccess(ITestResult result) {
22+
// TODO Auto-generated method stub
23+
TestBase.test.log(LogStatus.PASS, result.getName().toUpperCase()+"PASS");
24+
25+
}
26+
27+
public void onTestFailure(ITestResult result) {
28+
// TODO Auto-generated method stub
29+
System.setProperty("org.uncommons.reportng.escape-output","false");
30+
try {
31+
TestUtil.captureScreenshot();
32+
} catch (IOException e) {
33+
// TODO Auto-generated catch block
34+
e.printStackTrace();
35+
}
36+
Reporter.log("Click to see screenshot ");
37+
Reporter.log("log sucessfully executed");
38+
Reporter.log("<a target=\"_blank\" href="+TestUtil.screenshotName+"><img src="+TestUtil.screenshotName+" height=200 width=200></img>Screenshot</a>");
39+
/*Reporter.log("<a target=\"blank\" href=\"C:\\Users\\NipunSharma\\Pictures\\albums\\april2016\\img006_26628216905_o.jpg\">Screenshot</a>"); */
40+
41+
42+
43+
}
44+
45+
public void onTestSkipped(ITestResult result) {
46+
// TODO Auto-generated method stub
47+
48+
}
49+
50+
public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
51+
// TODO Auto-generated method stub
52+
53+
}
54+
55+
public void onStart(ITestContext context) {
56+
// TODO Auto-generated method stub
57+
58+
}
59+
60+
public void onFinish(ITestContext context) {
61+
// TODO Auto-generated method stub
62+
63+
}
64+
65+
66+
67+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.w2a.rough;
2+
3+
import java.util.Date;
4+
5+
public class TimeStamp {
6+
7+
public static void main(String[]args) {
8+
Date d= new Date();
9+
String screenshotName = d.toString().replaceAll(":", "_").replaceAll(" ", "_");
10+
System.out.println(screenshotName);
11+
System.out.println(d);
12+
}
13+
14+
}

src/test/java/com/w2a/testcases/AddCustomerTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.openqa.selenium.By;
77
import org.openqa.selenium.support.ui.ExpectedConditions;
88
import org.testng.Assert;
9+
import org.testng.Reporter;
910
import org.testng.annotations.DataProvider;
1011
import org.testng.annotations.Test;
1112

@@ -25,6 +26,9 @@ public void addCustomer(String firstName, String lastName, String postCode, Stri
2526
Assert.assertTrue(alert.getText().contains(alerttext));
2627

2728
alert.accept();
29+
Reporter.log("customer test successfull");
30+
Assert.fail("addcustomer test not successfull");
31+
2832

2933
}
3034

src/test/java/com/w2a/testcases/BankManagerLoginTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ public void loginAsbankManager() throws InterruptedException {
1515
driver.findElement(By.cssSelector(OR.getProperty("bmlBtn"))).click();
1616
Thread.sleep(3000);
1717
Assert.assertTrue(isElementpresent(By.cssSelector(OR.getProperty("addCustbtn"))), "login not succesfull");
18-
System.setProperty("org.uncommons.reportng.escape-output","false");
18+
1919
log.debug("log sucessfully executed");
20-
Reporter.log("log sucessfully executed");
21-
Reporter.log("<a target=\"blank\" href=\"C:\\Users\\NipunSharma\\Pictures\\albums\\april2016\\img006_26628216905_o.jpg\">Screenshot</a>");
2220

2321
}
2422

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<extentreports>
3+
<configuration>
4+
<!-- report theme -->
5+
<!-- standard, dark -->
6+
<theme>standard</theme>
7+
8+
<!-- document encoding -->
9+
<!-- defaults to UTF-8 -->
10+
<encoding>UTF-8</encoding>
11+
12+
<!-- protocol for script and stylesheets -->
13+
<!-- defaults to https -->
14+
<protocol>https</protocol>
15+
16+
<!-- title of the document -->
17+
<documentTitle>W2A Automation Reports</documentTitle>
18+
19+
<!-- report name - displayed at top-nav -->
20+
<reportName>Automation Report for</reportName>
21+
22+
<!-- report headline - displayed at top-nav, after reportHeadline -->
23+
<reportHeadline>Data Driven Framework</reportHeadline>
24+
25+
<!-- global date format override -->
26+
<!-- defaults to yyyy-MM-dd -->
27+
<dateFormat>yyyy-MM-dd</dateFormat>
28+
29+
<!-- global time format override -->
30+
<!-- defaults to HH:mm:ss -->
31+
<timeFormat>HH:mm:ss</timeFormat>
32+
33+
<!-- custom javascript -->
34+
<scripts>
35+
<![CDATA[
36+
$(document).ready(function() {
37+
38+
});
39+
]]>
40+
</scripts>
41+
42+
<!-- custom styles -->
43+
<styles>
44+
<![CDATA[
45+
46+
]]>
47+
</styles>
48+
</configuration>
49+
</extentreports>

0 commit comments

Comments
 (0)