Skip to content
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 loggers in collector/modifier #468

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to AET will be documented in this file.
- [PR-432](https://github.com/Cognifide/aet/pull/432) Fixed issue with lack of clear message for erroneous suite definition.
- [PR-363](https://github.com/Cognifide/aet/pull/363) Fixed saving case-level notes
- [PR-470](https://github.com/Cognifide/aet/pull/470) Security vulnerabilities fix ([#407](https://github.com/Cognifide/aet/issues/407))
- [PR-468](https://github.com/Cognifide/aet/pull/468) Add loggers in collector/modifier ([#446](https://github.com/Cognifide/aet/issues/446))

## Version 3.2.0

Expand All @@ -30,7 +31,7 @@ All notable changes to AET will be documented in this file.
- [PR-404](https://github.com/Cognifide/aet/pull/404) Added missing tooltip for conditional tests
- [PR-408](https://github.com/Cognifide/aet/pull/408) Advanced Screen Comparision button layout fix
- [PR-410](https://github.com/Cognifide/aet/pull/410) Notification that displays when exclude-elements are not found on page now shows what specific elements were not found([#372](https://github.com/Cognifide/aet/issues/372))

## Version 3.1.0

- [PR-409](https://github.com/Cognifide/aet/pull/409) Added sources link in "view source" url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AccessibilityCollector implements CollectorJob {

Expand All @@ -37,6 +39,8 @@ public class AccessibilityCollector implements CollectorJob {
private static final String PARAM_STANDARD = "standard";
private static final String DEFAULT_STANDARD = "WCAG2AA";

private static final Logger LOGGER = LoggerFactory.getLogger(AccessibilityCollector.class);

private final ArtifactsDAO artifactsDAO;
private final BundleContext context;
private final CollectorProperties properties;
Expand All @@ -55,6 +59,7 @@ public class AccessibilityCollector implements CollectorJob {
@Override
public CollectorStepResult collect() throws ProcessingException {
String script = getScriptFromFile();
LOGGER.debug("Executing Accessibility Collector");
final String html = jsExecutor.execute(DOCUMENT_OUTER_HTML_SCRIPT)
.getExecutionResultAsString();
final String json = jsExecutor.execute(script, standard).getExecutionResultAsString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public CollectorStepResult collect() throws ProcessingException {
CollectorStepResult result;
String jsSnippet = getJsSnippet();
try {
LOG.debug("Executing JavaScript Modifier");
jsExecutor.execute(jsSnippet);
result = CollectorStepResult.newModifierResult();
} catch (ProcessingException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private void hideElements(By locator, boolean leaveBlankSpace) throws Processing
.waitForElementToBePresent(webDriver, locator, getTimeoutInSeconds());

List<WebElement> webElements = webDriver.findElements(locator);
LOG.debug("Executing Hide Modifier");
for (WebElement element : webElements) {
jsExecutor.execute(script, element);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private void loginToForm() throws ProcessingException {
LoginFormComponent form = new LoginFormComponent(webDriver, config.getLoginInputSelector(),
config.getPasswordInputSelector(), config.getSubmitButtonSelector(),
new JavaScriptJobExecutor(webDriver));
LOGGER.debug("Executing Login Modifier");
form.login(config.getLogin(), config.getPassword());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private void replaceElements() throws ProcessingException {
.waitForElementToBePresent(webDriver, elementLocator, getTimeoutInSeconds());

List<WebElement> webElements = webDriver.findElements(elementLocator);
LOG.debug("Executing Replace Text Modifier");
for (WebElement element : webElements) {
jsExecutor.execute(script, element, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private int calculateWindowHeight() {
Supplier<Integer> heightSupplier = () -> {
int heightResult = HEIGHT_NOT_CALCULATED;
try {
LOG.debug("Executing Resolution Modifier");
heightResult = Integer.parseInt(
jsExecutor.execute(JAVASCRIPT_GET_BODY_HEIGHT).getExecutionResultAsString());
} catch (ProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.job.api.exceptions.ProcessingException;
import com.cognifide.aet.job.common.utils.javascript.JavaScriptJobExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

class ScrollModifier implements CollectorJob {

static final String NAME = "scroll";
private static final Logger LOG = LoggerFactory.getLogger(ScrollModifier.class);

private final ScrollModifierParamsParser parametersParser;
private final JavaScriptJobExecutor jsExecutor;
Expand All @@ -42,6 +46,7 @@ public void setParameters(Map<String, String> params) throws ParametersException
@Override
public CollectorStepResult collect() throws ProcessingException {
String jsSnippet = parametersParser.getJavaScriptSnippet();
LOG.debug("Executing Scroll Modifier");
jsExecutor.execute(jsSnippet);
return CollectorStepResult.newModifierResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private Boolean waitForImageCompletion(WebDriver webDriver) {
Boolean complete;
WebElement element = webDriver.findElement(getLocator());
try {
LOGGER.debug("Executing Wait For Image Completion Modifier");
complete = (Boolean) jsExecutor.execute("return arguments[0].complete", element)
.getExecutionResult()
.orElse(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public JavaScriptJobResult execute(String jsSnippet, Object... elements)

private JavaScriptJobResult executeJs(String jsSnippet, Object... elements) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Executing JavaScript command: {} on page: {}", jsSnippet, currentUrl);
LOGGER.trace("Executing JavaScript command: {} on page: {}", jsSnippet, currentUrl);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👍

}
Object jsResult = executor.executeScript(jsSnippet, elements);
return new JavaScriptJobResult(jsResult);
Expand Down