-
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
Selenium: Add ability to catch Chrome browser`s console logs #8502
Conversation
* | ||
* @return log messages from browser console | ||
*/ | ||
public String getBrowserLogsAsString() { |
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.
AsString
is redundant here
/** append browser logs to the test logs */ | ||
public void appendBrowserLogs() { | ||
getBrowserLogs() | ||
.forEach(logEntry -> LOG.info(format("%s %s", logEntry.getLevel(), logEntry.getMessage()))); |
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.
LOG.info("{} {}", logEntry.getLevel(), logEntry.getMessage())
is more suitable.
* @return log messages from browser console | ||
*/ | ||
public List<LogEntry> getBrowserLogs() { | ||
return seleniumWebDriver.manage().logs().get(LogType.BROWSER).getAll(); |
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 should be synchronized with loggingPreferences.enable(LogType.BROWSER, Level.SEVERE);
IMHO.
For example, we can use seleniumWebDriver.manage().logs().getAvailableLogTypes()
to check presence of certain type in the logs.
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.
May be we add possible pass LogType into getBrowserLogs(). It may be very useful for investigation very specific cases? We can change signature of the method or overload exist.
} | ||
|
||
public void open(TestWorkspace testWorkspace) throws Exception { | ||
URL workspaceUrl = testWorkspaceUrlResolver.resolve(testWorkspace); | ||
seleniumWebDriver.get(workspaceUrl.toString()); | ||
entrance.login(testWorkspace.getOwner()); | ||
try { | ||
projectExplorer.waitProjectExplorer(60); |
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.
Use timeout constant here.
} | ||
|
||
public void open(TestWorkspace testWorkspace) throws Exception { | ||
URL workspaceUrl = testWorkspaceUrlResolver.resolve(testWorkspace); | ||
seleniumWebDriver.get(workspaceUrl.toString()); | ||
entrance.login(testWorkspace.getOwner()); | ||
try { | ||
projectExplorer.waitProjectExplorer(60); |
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.
Not every open(ws)
requires waitProjectExplorer()
just after it. For example, CheckoutToRemoteBranchTest.
…d-browser-logs
…d-browser-logs
…d-browser-logs
Logs logs = seleniumWebDriver.manage().logs(); | ||
List<LogEntry> result = Collections.emptyList(); | ||
|
||
switch (logType) { |
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.
All switch-case statement could be replaced by one command:
return logs.get(logType).getAll();
*/ | ||
public List<LogEntry> getLogs(String logType) { | ||
Logs logs = seleniumWebDriver.manage().logs(); | ||
List<LogEntry> result = Collections.emptyList(); |
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.
result variable is redundant if we refactor code as mentioned here.
* @see LogType | ||
* @return provided type of browser logs | ||
*/ | ||
public List<LogEntry> getLogs(String logType) { |
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.
Also, it doesn't make sense to allow selection of log type which is differ from "browser" if we enabling only LogType.BROWSER
logging preference by command loggingPreferences.enable(LogType.BROWSER, Level.SEVERE);
in class SeleniumWebDriver.
/** | ||
* read and store browser logs to the test logs for change of logs level | ||
* | ||
* @see SeleniumWebDriver method "doCreateDriver" |
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.
Use {@link package.class#member label}
notation to reference method in the docs.
* read and store browser logs to the test logs for change of logs level | ||
* | ||
* @see SeleniumWebDriver method "doCreateDriver" | ||
* @see java.util.logging.Level |
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.
Use {@link package.class} notation to references class in the docs.
…3613 to master * commit 'd800fb816af6ed6f2d67702ac55ff5f8a8be3630': (34 commits) fixed version added new aws run script Prevents displaying installers with empty names and descriptions (eclipse-che#8536) adapt selenium tests according to changes with workspace config updating (eclipse-che#8561) Fix docs link. Dash instead underscore (eclipse-che#8548) fix aws ST-3613 custom keycloak image Dashboard: allow to update workspace config without workpace restarting (eclipse-che#8505) eclipse-che#8509 handle keybinding inside FileStructure Window (eclipse-che#8528) RELEASE: Set next development version (eclipse-che#8496) Add extra steps in the 'prepare()' to increase stability Renew URLs of CI servers to compare local selenium testing results (eclipse-che#8541) Selenium: Add ability to catch Chrome browser`s console logs (eclipse-che#8502) CHE-6923: Provide more space for committer fields in Preferences dialog. (eclipse-che#8480) Restore support of single-port Che mode (on docker infra) Factories links (eclipse-che#8530) CHE-7555 fix resolve factory flow Update policy of installers update (eclipse-che#8406) Improves debug panel, fixes UI of configure breakpoints popup (eclipse-che#8520) Update ProjectExplorerPresenter.java ...
What does this PR do?
Add ability to catch Chrome browser`s console logs
Output example:
What issues does this PR fix or reference?
Issue: #8469
Release Notes
Docs PR