Skip to content

Commit 2e89d8e

Browse files
committed
remove JQuery wait in screenshot method
1 parent 7afcb04 commit 2e89d8e

File tree

5 files changed

+54
-41
lines changed

5 files changed

+54
-41
lines changed

src/test/java/com/anhtester/hooks/CucumberListener.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
public class CucumberListener implements EventListener {
1919

2020
//Khai báo các biến để thống kê tổng số test cases sau khi kết thúc test
21-
public static int count_totalTCs;
22-
public static int count_passedTCs;
23-
public static int count_skippedTCs;
24-
public static int count_failedTCs;
21+
public static int count_totalTCs = 0;
22+
public static int count_passedTCs = 0;
23+
public static int count_skippedTCs = 0;
24+
public static int count_failedTCs = 0;
2525

2626
@Override
2727
public void setEventPublisher(EventPublisher publisher) {
@@ -48,15 +48,15 @@ private void runFinished(TestRunFinished event) {
4848
// This event is triggered when feature file is read
4949
// here we create the feature node
5050
private void featureRead(TestSourceRead event) {
51-
String featurePath = event.getUri().toString();
52-
String featureName = featurePath.split(".*/")[1];
53-
LogUtils.info("Feature Path: " + featurePath);
54-
LogUtils.info("Feature Name: " + featureName);
51+
// String featurePath = event.getUri().toString();
52+
// String featureName = featurePath.split(".*/")[1];
53+
// LogUtils.info("Feature Path: " + featurePath);
54+
// LogUtils.info("Feature Name: " + featureName);
5555
}
5656

5757
private void ScenarioStarted(TestCaseStarted event) {
58-
LogUtils.info("Scenario Path: " + event.getTestCase().getUri().toString());
59-
LogUtils.info("Scenario Name: " + event.getTestCase().getName());
58+
// LogUtils.info("Scenario Path: " + event.getTestCase().getUri().toString());
59+
// LogUtils.info("Scenario Name: " + event.getTestCase().getName());
6060
count_totalTCs = count_totalTCs + 1;
6161
}
6262

@@ -72,10 +72,6 @@ private void ScenarioFinished(TestCaseFinished event) {
7272
if (Status.SKIPPED.equals(result.getStatus())) {
7373
count_skippedTCs = count_skippedTCs + 1;
7474
}
75-
76-
//Quit driver in thread local
77-
DriverManager.quit();
78-
WebUI.stopSoftAssertAll();
7975
}
8076

8177
// Step started event

src/test/java/com/anhtester/hooks/Hooks.java

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020

2121
public 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");

src/test/java/com/anhtester/runners/TestRunnerAllFeatureByTag.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,28 @@
1212
@Test
1313
@CucumberOptions(
1414
features = "src/test/resources/features",
15-
glue = {"com.anhtester.projects.website.crm.stepdefinitions",
15+
glue = {
16+
"com.anhtester.projects.website.crm.stepdefinitions",
1617
"com.anhtester.projects.website.cms.stepdefinitions",
1718
"com.anhtester.projects.website.hrm.stepdefinitions",
18-
"com.anhtester.hooks"},
19-
plugin = {"com.anhtester.hooks.CucumberListener",
19+
"com.anhtester.hooks"
20+
},
21+
plugin = {
22+
"com.anhtester.hooks.CucumberListener",
2023
"pretty",
2124
"html:target/cucumber-reports/cucumber-reports.html",
2225
"json:target/cucumber-reports/cucumber-reports.json",
2326
"io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm",
24-
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"}
25-
, monochrome = true,
27+
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"
28+
},
29+
monochrome = true,
2630
tags = "@Regression or @Smoke"
2731
)
2832

2933
public class TestRunnerAllFeatureByTag extends AbstractTestNGCucumberTests {
3034
@Override
31-
@DataProvider(parallel = false)
35+
@DataProvider(parallel = true)
3236
public Object[][] scenarios() {
3337
return super.scenarios();
3438
}
35-
36-
@AfterSuite
37-
public void afterSuite() {
38-
System.out.println("================ AFTER SUITE ================");
39-
ZipUtils.zipReportFolder();
40-
EmailSendUtils.sendEmail(CucumberListener.count_totalTCs
41-
, CucumberListener.count_passedTCs
42-
, CucumberListener.count_failedTCs
43-
, CucumberListener.count_skippedTCs);
44-
}
4539
}

src/test/resources/features/Dashboard.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Feature: HRM dashboard page
33
Background: User is logged to the HRM system
44
Given User logged in with email "admin_example" and password "123456"
55

6-
@Regression
6+
@Regression @device_Window_11 @author_AnhTester
77
Scenario Outline: Open menu
88
Given User navigate to dashboard
99
When User click "<menu>"

src/test/resources/features/SigninCRM.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Feature: Sign in page CRM
22

3-
@Regression
3+
@Regression @device_Window_10 @author_AnVo
44
Scenario Outline: Sign in CRM with an email valid
55
Given User navigate to url "<url>"
66
When User login with username "<username>" and password "<password>" valid
@@ -9,7 +9,7 @@ Feature: Sign in page CRM
99
| url | username | password |
1010
| https://rise.fairsketch.com/signin | admin@demo.com | riseDemo |
1111

12-
@Smoke
12+
@Smoke @device_Window_10 @author_AnVo
1313
Scenario Outline: Sign in CRM with an email invalid
1414
Given User navigate to url "<url>"
1515
When User login with username "<username>" and password "<password>" invalid

0 commit comments

Comments
 (0)