@@ -61,36 +61,34 @@ public static synchronized SeleniumProvider getInstance() {
61
61
public void onFailed (ExtensionContext extensionContext ) {
62
62
String getTestClassName = extensionContext .getTestClass ().get ().getName ();
63
63
String getTestMethodName = extensionContext .getTestMethod ().get ().getName ();
64
- saveBrowserLog (getTestClassName , getTestMethodName );
65
- saveScreenShots (getTestClassName , getTestMethodName );
64
+ Path webConsolePath = getWebConsolePath (Environment .getInstance ().testLogDir (), getTestClassName , getTestMethodName );
65
+ saveBrowserLog (webConsolePath );
66
+ SeleniumManagement .collectAppLogs (webConsolePath );
67
+ saveScreenShots (webConsolePath , getTestClassName , getTestMethodName );
68
+
66
69
}
67
70
68
- public void saveBrowserLog (String className , String methodName ) {
71
+ private void saveBrowserLog (Path path ) {
69
72
try {
70
73
log .info ("Saving browser console log..." );
71
- Path path = Paths .get (
72
- Environment .getInstance ().testLogDir (),
73
- webconsoleFolder ,
74
- className ,
75
- methodName );
76
74
Files .createDirectories (path );
77
75
File consoleLog = new File (path .toString (), "browser_console.log" );
78
76
StringBuilder logEntries = formatedBrowserLogs ();
79
77
Files .write (Paths .get (consoleLog .getPath ()), logEntries .toString ().getBytes ());
80
- log .info ("Browser console log saved successfully" );
78
+ log .info ("Browser console log saved successfully : {}" , consoleLog );
81
79
} catch (Exception ex ) {
82
80
log .warn ("Cannot save browser log: " + ex .getMessage ());
83
81
}
84
82
}
85
83
86
84
public void saveScreenShots (String className , String methodName ) {
85
+ Path webConsolePath = getWebConsolePath (Environment .getInstance ().testLogDir (), className , methodName );
86
+ saveScreenShots (webConsolePath , className , methodName );
87
+ }
88
+
89
+ private void saveScreenShots (Path path , String className , String methodName ) {
87
90
try {
88
91
takeScreenShot ();
89
- Path path = Paths .get (
90
- Environment .getInstance ().testLogDir (),
91
- webconsoleFolder ,
92
- className ,
93
- methodName );
94
92
Files .createDirectories (path );
95
93
for (Date key : browserScreenshots .keySet ()) {
96
94
FileUtils .copyFile (browserScreenshots .get (key ), new File (Paths .get (path .toString (),
@@ -100,7 +98,7 @@ public void saveScreenShots(String className, String methodName) {
100
98
} catch (Exception ex ) {
101
99
log .warn ("Cannot save screenshots: " + ex .getMessage ());
102
100
} finally {
103
- tearDownDrivers ();
101
+ // tearDownDrivers();
104
102
}
105
103
}
106
104
@@ -286,6 +284,14 @@ public void waitUntilItemNotPresent(int timeInSeconds, Supplier<WebItem> item) t
286
284
waitUntilItem (timeInSeconds , item , false );
287
285
}
288
286
287
+ private Path getWebConsolePath (String target , String className , String methodName ) {
288
+ return Paths .get (
289
+ target ,
290
+ webconsoleFolder ,
291
+ className ,
292
+ methodName );
293
+ }
294
+
289
295
private <T extends WebItem > T waitUntilItem (int timeInSeconds , Supplier <T > item , boolean present ) throws Exception {
290
296
log .info ("Waiting for element be present" );
291
297
int attempts = 0 ;
0 commit comments