2020
2121public class Hooks {
2222
23+ public static int count_totalTCs = 0 ;
24+ public static int count_passedTCs = 0 ;
25+ public static int count_skippedTCs = 0 ;
26+ public static int count_failedTCs = 0 ;
27+
2328 TestContext testContext ;
2429
2530 public Hooks (TestContext context ) {
@@ -29,7 +34,7 @@ public Hooks(TestContext context) {
2934 @ BeforeAll
3035 public static void before_all () {
3136 LogUtils .info ("================ BEFORE ALL ================" );
32- PropertiesHelpers .loadAllFiles (); //Load Config and Locators
37+ PropertiesHelpers .loadAllFiles ();
3338 AllureManager .setAllureEnvironmentInformation ();
3439
3540 try {
@@ -50,15 +55,21 @@ public static void before_all() {
5055 public static void after_all () {
5156 LogUtils .info ("================ AFTER ALL ================" );
5257 ZipUtils .zipReportFolder ();
53- EmailSendUtils .sendEmail (CucumberListener .count_totalTCs
54- , CucumberListener .count_passedTCs
55- , CucumberListener .count_failedTCs
56- , CucumberListener .count_skippedTCs );
58+ EmailSendUtils .sendEmail (count_totalTCs
59+ , count_passedTCs
60+ , count_failedTCs
61+ , count_skippedTCs );
62+
63+ LogUtils .info ("count_totalTCs: " + count_totalTCs );
64+ LogUtils .info ("count_passedTCs: " + count_passedTCs );
65+ LogUtils .info ("count_failedTCs: " + count_failedTCs );
66+ LogUtils .info ("count_skippedTCs: " + count_skippedTCs );
5767 }
5868
5969 @ Before
6070 public void beforeScenario (Scenario scenario ) {
6171 LogUtils .info ("Scenario Name: " + scenario .getName ());
72+ count_totalTCs = count_totalTCs + 1 ;
6273
6374 if (VIDEO_RECORD .toLowerCase ().trim ().equals (YES )) {
6475 CaptureHelpers .startRecord (scenario .getName ());
@@ -67,31 +78,43 @@ public void beforeScenario(Scenario scenario) {
6778
6879 @ After
6980 public void afterScenario (Scenario scenario ) {
81+
82+ if (Status .PASSED .equals (scenario .getStatus ())) {
83+ count_passedTCs = count_passedTCs + 1 ;
84+ }
85+ if (Status .FAILED .equals (scenario .getStatus ())) {
86+ count_failedTCs = count_failedTCs + 1 ;
87+ }
88+ if (Status .SKIPPED .equals (scenario .getStatus ())) {
89+ count_skippedTCs = count_skippedTCs + 1 ;
90+ }
91+
7092 if (VIDEO_RECORD .toLowerCase ().trim ().equals (YES )) {
7193 WebUI .sleep (1 );
7294 CaptureHelpers .stopRecord ();
7395 }
96+
97+ //Quit driver in thread local
98+ DriverManager .quit ();
99+ WebUI .stopSoftAssertAll ();
74100 }
75101
76102 @ AfterStep
77103 public void afterStep (Scenario scenario ) {
78104 if (scenario .getStatus ().equals (Status .PASSED ) && SCREENSHOT_PASSED_STEPS .equals (YES )) {
79105 WebUI .waitForPageLoaded ();
80- WebUI .waitForJQueryLoad ();
81106
82107 byte [] screenshot = ((TakesScreenshot ) DriverManager .getDriver ()).getScreenshotAs (OutputType .BYTES );
83108 scenario .attach (screenshot , "image/png" , "Screenshot passed step" );
84109 }
85110 if (scenario .getStatus ().equals (Status .FAILED ) && SCREENSHOT_FAILED_STEPS .equals (YES )) {
86111 WebUI .waitForPageLoaded ();
87- WebUI .waitForJQueryLoad ();
88112
89113 byte [] screenshot = ((TakesScreenshot ) DriverManager .getDriver ()).getScreenshotAs (OutputType .BYTES );
90114 scenario .attach (screenshot , "image/png" , "Screenshot failed step" );
91115 }
92116 if (SCREENSHOT_ALL_STEPS .equals (YES )) {
93117 WebUI .waitForPageLoaded ();
94- WebUI .waitForJQueryLoad ();
95118
96119 byte [] screenshot = ((TakesScreenshot ) DriverManager .getDriver ()).getScreenshotAs (OutputType .BYTES );
97120 scenario .attach (screenshot , "image/png" , "Screenshot step" );
0 commit comments