-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability storing of webdriver console and network logs after failing tests #8926
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0fa6a51
change webdriver log level and study how to get most important data J…
f8cba6f
Test logging
b5f4e52
Merge branch 'master' into che#8857
f34a6a7
apply storing logs to SeleniumHandler
a362d20
final rework of BrowserLogsUtil class and apply renamed methods
8c668f0
rename methods according to proposals for the PR
b2167c8
rename method
360b707
Rename BrowserUtilsLog class, revert DI to the related class. Replace…
ac41500
remove unnecessary WebDriver injections
5e1ab4f
add add few logs messages for problem detection
vparfonov 0d00d06
rename method
b3fe3f4
fix name of methos and javadoc
85f4efc
remove unnecessary static declarations from the WebDriverLogsReader
9861ae2
Merge branch 'che#8857' of github.com:eclipse/che into che#8857
vparfonov b1eab7c
remove unnecessary static declarations from the WebDriverLogsReader.
97d9bca
Merge branch 'che#8857' of github.com:eclipse/che into che#8857
vparfonov 3db9bf2
Add few log messages on server side
vparfonov ce0cf6b
Make network logs readable; add websocket logs; remove duplicating pr…
cec456d
Fix store web driver output error message
423417f
Add javadocs, fix method names
44b7466
Merge remote-tracking branch 'origin/master' into che#8857
a2a2be2
Clean up code
ae5ede8
Fix time format in webdriver logs
be9f972
Revert "add add few logs messages for problem detection"
d33badc
Merge remote-tracking branch 'origin/master' into che#8857
c8930f2
Revert commit 'add add few logs messages for problem detection'
66c3ef5
Housekeeping
925fbf7
Clean up
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
.../che-selenium-core/src/main/java/org/eclipse/che/selenium/core/utils/BrowserLogsUtil.java
This file was deleted.
Oops, something went wrong.
156 changes: 156 additions & 0 deletions
156
...nium/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/webdriver/log/Log.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.selenium.core.webdriver.log; | ||
|
||
import static java.lang.String.format; | ||
import static org.eclipse.che.selenium.core.webdriver.log.WebDriverLogsReader.LOG_TIME_FORMAT; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
/** | ||
* This class deals with web driver log entry. | ||
* | ||
* @author Dmytro Nochevnov | ||
*/ | ||
public class Log { | ||
private Message message; | ||
private long timestamp; | ||
|
||
public Message getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(Message message) { | ||
this.message = message; | ||
} | ||
|
||
boolean isNetworkLog() { | ||
return isNetworkRequest() | ||
|| isNetworkResponse() | ||
|| isWebsocketCreated() | ||
|| isWebsocketRequest() | ||
|| isWebsocketResponse(); | ||
} | ||
|
||
private boolean isNetworkRequest() { | ||
return "Network.requestWillBeSent".equals(getMessage().getMethod()); | ||
} | ||
|
||
private boolean isNetworkResponse() { | ||
return "Network.responseReceived".equals(getMessage().getMethod()); | ||
} | ||
|
||
private boolean isWebsocketCreated() { | ||
return "Network.webSocketCreated".equals(getMessage().getMethod()); | ||
} | ||
|
||
private boolean isWebsocketRequest() { | ||
return "Network.webSocketFrameSent".equals(getMessage().getMethod()); | ||
} | ||
|
||
private boolean isWebsocketResponse() { | ||
return "Network.webSocketFrameReceived".equals(getMessage().getMethod()); | ||
} | ||
|
||
public String getUrl() { | ||
if (hasRequest()) { | ||
return getMessage().getParams().getRequest().getUrl(); | ||
|
||
} else if (hasResponse()) { | ||
return getMessage().getParams().getResponse().getUrl(); | ||
|
||
} else if (hasParams() && getMessage().getParams().getUrl() != null) { | ||
return getMessage().getParams().getUrl(); | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
public String getRequestId() { | ||
if (hasParams()) { | ||
return getMessage().getParams().getRequestId(); | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
public long getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public void setTimestamp(long timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
|
||
private String getRequestMethod() { | ||
if (hasRequest()) { | ||
return getMessage().getParams().getRequest().getMethod(); | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
private String getResponseStatus() { | ||
if (hasResponse()) { | ||
return getMessage().getParams().getResponse().getStatus(); | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
private String getPayloadData() { | ||
if (hasResponse()) { | ||
return getMessage().getParams().getResponse().getPayloadData(); | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
private boolean hasRequest() { | ||
return hasParams() && getMessage().getParams().getRequest() != null; | ||
} | ||
|
||
private boolean hasResponse() { | ||
return hasParams() && getMessage().getParams().getResponse() != null; | ||
} | ||
|
||
private boolean hasParams() { | ||
return getMessage() != null && getMessage().getParams() != null; | ||
} | ||
|
||
private String formatTime(long timestamp) { | ||
return new SimpleDateFormat(LOG_TIME_FORMAT).format(new Date(timestamp)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String prefix = format("%s (id: %s)", formatTime(getTimestamp()), getRequestId()); | ||
|
||
if (isNetworkRequest()) { | ||
return format("%s [REQUEST] %s %s\n", prefix, getRequestMethod(), getUrl()); | ||
|
||
} else if (isNetworkResponse()) { | ||
return format("%s [RESPONSE] %s %s\n", prefix, getResponseStatus(), getUrl()); | ||
|
||
} else if (isWebsocketCreated()) { | ||
return format("%s [WEBSOCKET_CREATED] %s\n", prefix, getUrl()); | ||
|
||
} else if (isWebsocketRequest()) { | ||
return format("%s [WEBSOCKET_REQUEST] %s\n", prefix, getPayloadData()); | ||
|
||
} else if (isWebsocketResponse()) { | ||
return format("%s [WEBSOCKET_RESPONSE] %s\n", prefix, getPayloadData()); | ||
} | ||
|
||
return super.toString(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../che-selenium-core/src/main/java/org/eclipse/che/selenium/core/webdriver/log/Message.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.selenium.core.webdriver.log; | ||
|
||
/** | ||
* This is POJO to extract message from web driver network log entry | ||
* | ||
* @author Dmytro Nochevnov | ||
*/ | ||
public interface Message { | ||
String getMethod(); | ||
|
||
void setMethod(String method); | ||
|
||
Params getParams(); | ||
|
||
void setParams(Params params); | ||
} |
38 changes: 38 additions & 0 deletions
38
...m/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/webdriver/log/Params.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.selenium.core.webdriver.log; | ||
|
||
/** | ||
* This is POJO to extract 'params' value from web driver network log entry | ||
* | ||
* @author Dmytro Nochevnov | ||
*/ | ||
public interface Params { | ||
String getRequestId(); | ||
|
||
void setRequestId(String requestId); | ||
|
||
String getUrl(); | ||
|
||
void setUrl(String url); | ||
|
||
Request getRequest(); | ||
|
||
void setRequest(Request request); | ||
|
||
Response getResponse(); | ||
|
||
void setResponse(Response request); | ||
|
||
String getTimestamp(); | ||
|
||
void setTimestamp(String timestamp); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was
Level.SEVERE
used for some reasons.@Ohrimenko1988: please, comment on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was used because only browser errors have useful information for us. But it only in case for browser's console output. In other cases (for example "Networking"), logs of other levels may be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ALL levels log also can have important info