From 9388e5176550556581561cdfcf1472493266f1ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 May 2021 05:31:43 +0000 Subject: [PATCH 1/7] Bump release-drafter/release-drafter from 5.14.0 to 5.15.0 Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5.14.0 to 5.15.0. - [Release notes](https://github.com/release-drafter/release-drafter/releases) - [Commits](https://github.com/release-drafter/release-drafter/compare/v5.14.0...v5.15.0) Signed-off-by: dependabot[bot] --- .github/workflows/snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index ff9ae3e21..cf340e783 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Draft Release Notes id: release-drafter - uses: release-drafter/release-drafter@v5.14.0 + uses: release-drafter/release-drafter@v5.15.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - id: bash_v From d316ba944b8a26b5115428fb04c53e102cd1fca8 Mon Sep 17 00:00:00 2001 From: Jon Reding Date: Fri, 15 Oct 2021 15:05:23 -0500 Subject: [PATCH 2/7] Accessibility fix issues (#547) * started work on the add fixes method * resolved issue with nodes/checkedNodes * deleted empty line * added the fix issue methods added in the C# version * added the fix issue methods added in the C# version * added the fix issue methods added in the C# version * added comments to methods * got rid of the hash set selectors variable. It is not needed * code smell resolution * code smell resolution * code smell resolution * managing spelling * managing spelling * update axe version * delete .name() extension of result type. It is called later on * updated HtmlReporter --- .../accessibility/AccessibilityUtilities.java | 39 ++- .../jmaqs/accessibility/HtmlReporter.java | 269 +++++++++++++++--- .../AccessibilityHTMLUnitTest.java | 6 +- 3 files changed, 261 insertions(+), 53 deletions(-) diff --git a/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/AccessibilityUtilities.java b/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/AccessibilityUtilities.java index 3542bda92..dd7e3e0a4 100644 --- a/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/AccessibilityUtilities.java +++ b/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/AccessibilityUtilities.java @@ -81,7 +81,7 @@ public static void checkAccessibility(WebDriver webDriver, Logger logger, boolea * @param logger Where you want the check logged to * @param checkType What kind of check is being run * @param getResults Function for getting Axe results - * @param loggingLevel What level should log check take, + * @param loggingLevel What level should the logging check take, * this gets used if the check doesn't throw an exception * @param throwOnResults Throw error if any results are found */ @@ -100,7 +100,7 @@ public static void checkAccessibility(WebDriver webDriver, Logger logger, String * Run axe accessibility and log the results. * @param webDriver The web driver that is on the page you want to run the accessibility check on * @param logger Where you want the check logged to - * @param loggingLevel What level should log check take, + * @param loggingLevel What level should the logging check take, * this gets used if the check doesn't throw an exception */ public static void checkAccessibilityPasses(WebDriver webDriver, Logger logger, MessageType loggingLevel) { @@ -112,7 +112,7 @@ public static void checkAccessibilityPasses(WebDriver webDriver, Logger logger, * Run axe accessibility and log the results. * @param webDriver The web driver that is on the page you want to run the accessibility check on * @param logger Where you want the check logged to - * @param loggingLevel What level should log check take, + * @param loggingLevel What level should the logging check take, * this gets used if the check doesn't throw an exception * @param throwOnInapplicable Should inapplicable cause an exception to be thrown */ @@ -126,7 +126,7 @@ public static void checkAccessibilityInapplicable(WebDriver webDriver, Logger lo * Run axe accessibility and log the results. * @param webDriver The web driver that is on the page you want to run the accessibility check on * @param logger Where you want the check logged to - * @param loggingLevel What level should log check take, + * @param loggingLevel What level should the logging check take, * this gets used if the check doesn't throw an exception * @param throwOnIncomplete Should incomplete cause an exception to be thrown */ @@ -140,7 +140,7 @@ public static void checkAccessibilityIncomplete(WebDriver webDriver, Logger logg * Run axe accessibility and log the results. * @param webDriver The web driver that is on the page you want to run the accessibility check on * @param logger Where you want the check logged to - * @param loggingLevel What level should log check take, + * @param loggingLevel What level should the logging check take, * this gets used if the check doesn't throw an exception * @param throwOnViolation Should violations cause an exception to be thrown */ @@ -154,6 +154,8 @@ public static void checkAccessibilityViolations(WebDriver webDriver, Logger logg * Create an HTML accessibility report for an entire web page. * @param testObject The TestObject to associate the report with * @param throwOnViolation Should violations cause an exception to be thrown + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown */ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, boolean throwOnViolation) throws IOException, ParseException { @@ -165,6 +167,8 @@ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, * Create an HTML accessibility report for an entire web page. * @param testObject The TestObject to associate the report with * @param throwOnViolation Should violations cause an exception to be thrown + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown */ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, boolean throwOnViolation, Set requestedResult) throws IOException, ParseException { @@ -176,6 +180,8 @@ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, * Create an HTML accessibility report for an entire web page. * @param testObject The TestObject to associate the report with * @param throwOnViolation Should violations cause an exception to be thrown + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown */ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, WebElement element, boolean throwOnViolation) throws IOException, ParseException { @@ -188,6 +194,8 @@ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, * Create an HTML accessibility report for an entire web page. * @param testObject The TestObject to associate the report with * @param throwOnViolation Should violations cause an exception to be thrown + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown */ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, WebElement element, boolean throwOnViolation, Set resultRequested) @@ -196,11 +204,28 @@ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, () -> new AxeBuilder().analyze(testObject.getWebDriver(), element), throwOnViolation, resultRequested); } + /** + * Create HTML accessibility report for an entire web page. + * @param testObject The TestObject to associate the report with + * @param result The result object + * @param throwOnViolation Should violations cause an exception to be thrown + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, Results result, boolean throwOnViolation) throws IOException, ParseException { createAccessibilityHtmlReport(testObject, result, throwOnViolation, EnumSet.allOf(ResultType.class)); } + /** + * Create HTML accessibility report for an entire web page. + * @param testObject The TestObject to associate the report with + * @param result The result object + * @param throwOnViolation Should violations cause an exception to be thrown + * @param resultRequested A set list of enum types from the Result Type enum class + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, Results result, boolean throwOnViolation, Set resultRequested) throws IOException, ParseException { createAccessibilityHtmlReport(testObject, () -> result, throwOnViolation, resultRequested); @@ -211,6 +236,8 @@ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, * @param testObject The TestObject to associate the report with * @param getResults Function for getting the accessibility scan results * @param throwOnViolation Should violations cause an exception to be thrown + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown */ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, Supplier getResults, boolean throwOnViolation, @@ -243,7 +270,7 @@ public static void createAccessibilityHtmlReport(SeleniumTestObject testObject, testObject.getLogger().logMessage(MessageType.INFORMATION, "Ran accessibility check and created HTML report: " + report + " "); - // Throw exception if we found violations when we want that to cause an error + // Throw exception if we found any violations, we want that to cause an error if (throwOnViolation && !getResults.get().getViolations().isEmpty()) { throw new AxeRuntimeException(new Exception(System.lineSeparator() + "Accessibility violations, see: " + report + " for more details.")); diff --git a/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/HtmlReporter.java b/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/HtmlReporter.java index 28c6c6021..a4bbfe8eb 100644 --- a/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/HtmlReporter.java +++ b/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/HtmlReporter.java @@ -4,7 +4,8 @@ package com.magenic.jmaqs.accessibility; -import com.deque.html.axecore.results.Node; +import com.deque.html.axecore.results.Check; +import com.deque.html.axecore.results.CheckedNode; import com.deque.html.axecore.results.Results; import com.deque.html.axecore.results.Rule; import com.deque.html.axecore.selenium.AxeBuilder; @@ -19,7 +20,6 @@ import java.util.Collections; import java.util.Date; import java.util.EnumSet; -import java.util.HashSet; import java.util.List; import java.util.Set; import org.apache.commons.io.FileUtils; @@ -39,54 +39,125 @@ */ public class HtmlReporter { - private static final String classString = "class"; + /** + * Placeholder for class tag string type. + */ + private static final String CLASS = "class"; + /** + * Placeholder for wrap one tag string type. + */ + private static final String WRAP_ONE = "wrapOne"; + + /** + * File path to resources java resources folder. + */ private static final String resourcesFile = "../jmaqs-accessibility/src/main/resources/"; + /** + * Class constructor. + */ protected HtmlReporter() { } + /** + * Creates a Html report with All result types. + * @param webDriver The web driver to be used for the scan + * @param destination The file path where the html report will be stored + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ public static void createAxeHtmlReport(WebDriver webDriver, String destination) throws IOException, ParseException { createAxeHtmlReport(webDriver, destination, EnumSet.allOf(ResultType.class)); } + /** + * Creates a Html report with a list of specified result types. + * @param webDriver The web driver to be used for the scan + * @param destination The file path where the html report will be stored + * @param requestedResults The result types that will be included on the html report + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ public static void createAxeHtmlReport(WebDriver webDriver, String destination, Set requestedResults) throws IOException, ParseException { createAxeHtmlReport(webDriver, new AxeBuilder().analyze(webDriver), destination, requestedResults); } + /** + * Creates a Html report with All result types. + * @param webDriver The web driver to be used for the scan + * @param element The element that will be reported on + * @param destination The file path where the html report will be stored + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ public static void createAxeHtmlReport(WebDriver webDriver, WebElement element, String destination) throws IOException, ParseException { createAxeHtmlReport(webDriver, element, destination, EnumSet.allOf(ResultType.class)); } + /** + * Creates a Html report with a list of specified result types. + * @param webDriver The web driver to be used for the scan + * @param element The element that will be reported on + * @param destination The file path where the html report will be stored + * @param requestedResults The result types that will be included on the html report + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ public static void createAxeHtmlReport(WebDriver webDriver, WebElement element, String destination, Set requestedResults) throws IOException, ParseException { createAxeHtmlReport(webDriver, new AxeBuilder().analyze(webDriver, element), destination, requestedResults); } + /** + * Creates a Html report with All result types. + * @param webDriver The web driver to be used for the scan + * @param results The results that will be used for the html report + * @param destination The file path where the html report will be stored + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ public static void createAxeHtmlReport(WebDriver webDriver, Results results, String destination) throws IOException, ParseException { createAxeHtmlReport(webDriver, results, destination, EnumSet.allOf(ResultType.class)); } + /** + * Creates a Html report with a list of specified result types. + * @param webDriver The web driver to be used for the scan + * @param results The results that will be used for the html report + * @param destination The file path where the html report will be stored + * @param requestedResults The result types that will be included on the html report + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ public static void createAxeHtmlReport(WebDriver webDriver, Results results, String destination, Set requestedResults) throws IOException, ParseException { createAxeHtmlReportFile(webDriver, results, destination, requestedResults); } + /** + * Creates a Html report. + * @param context the web driver or web element to be used for the scan + * @param results The results that will be used for the html report + * @param destination The file path where the html report will be stored + * @param requestedResults The result types that will be included on the html report + * @throws IOException If an IO exception is thrown + * @throws ParseException If a parse exception is thrown + */ private static void createAxeHtmlReportFile(SearchContext context, Results results, String destination, Set requestedResults) throws IOException, ParseException { // Get the unwrapped element if we are using a wrapped element context = (context instanceof WrapsElement) ? ((WrapsElement) context).getWrappedElement() : context; - HashSet selectors = new HashSet<>(); - final int violationCount = getCount(results.getViolations(), selectors); - final int incompleteCount = getCount(results.getIncomplete(), selectors); - final int passCount = getCount(results.getPasses(), selectors); - final int inapplicableCount = getCount(results.getInapplicable(), selectors); + final int violationCount = getCount(results.getViolations()); + final int incompleteCount = getCount(results.getIncomplete()); + final int passCount = getCount(results.getPasses()); + final int inapplicableCount = getCount(results.getInapplicable()); String stringBuilder = "\r\n" + "" + "" + "" @@ -117,7 +188,7 @@ private static void createAxeHtmlReportFile(SearchContext context, Results resul contextGroup.appendChild(contextHeader); Element contextContent = new Element("div"); - contextContent.attributes().put(classString, "emOne"); + contextContent.attributes().put(CLASS, "emOne"); contextContent.attributes().put("id", "reportContext"); getContextContent(results, contextContent); contextGroup.appendChild(contextContent); @@ -131,7 +202,7 @@ private static void createAxeHtmlReportFile(SearchContext context, Results resul imgGroup.appendChild(imageHeader); Element imageContent = new Element("img"); - imageContent.attributes().put(classString, "thumbnail"); + imageContent.attributes().put(CLASS, "thumbnail"); imageContent.attributes().put("id", "screenshotThumbnail"); imageContent.attributes().put("alt", "A Screenshot of the page"); imageContent.attributes().put("width", "33%"); @@ -147,7 +218,7 @@ private static void createAxeHtmlReportFile(SearchContext context, Results resul countsGroup.appendChild(countsHeader); Element countsContent = new Element("div"); - countsContent.attributes().put(classString, "emOne"); + countsContent.attributes().put(CLASS, "emOne"); getCountContent(violationCount, incompleteCount, passCount, inapplicableCount, requestedResults, countsContent); countsGroup.appendChild(countsContent); @@ -155,7 +226,6 @@ private static void createAxeHtmlReportFile(SearchContext context, Results resul resultsFlex.attributes().put("id", "results"); contentArea.appendChild(resultsFlex); - if (results.isErrored()) { Element errorHeader = new Element("h2"); errorHeader.appendText("SCAN ERRORS:"); @@ -168,19 +238,19 @@ private static void createAxeHtmlReportFile(SearchContext context, Results resul } if (violationCount > 0 && requestedResults.contains(ResultType.Violations)) { - getReadableAxeResults(results.getViolations(), ResultType.Violations.name(), resultsFlex); + getReadableAxeResults(results.getViolations(), ResultType.Violations, resultsFlex); } if (incompleteCount > 0 && requestedResults.contains(ResultType.Incomplete)) { - getReadableAxeResults(results.getIncomplete(), ResultType.Incomplete.name(), resultsFlex); + getReadableAxeResults(results.getIncomplete(), ResultType.Incomplete, resultsFlex); } if (passCount > 0 && requestedResults.contains(ResultType.Passes)) { - getReadableAxeResults(results.getPasses(), ResultType.Passes.name(), resultsFlex); + getReadableAxeResults(results.getPasses(), ResultType.Passes, resultsFlex); } if (inapplicableCount > 0 && requestedResults.contains(ResultType.Inapplicable)) { - getReadableAxeResults(results.getInapplicable(), ResultType.Inapplicable.name(), resultsFlex); + getReadableAxeResults(results.getInapplicable(), ResultType.Inapplicable, resultsFlex); } Element modal = new Element("div"); @@ -202,42 +272,46 @@ private static void createAxeHtmlReportFile(SearchContext context, Results resul FileUtils.writeStringToFile(new File(destination), doc.outerHtml(), StandardCharsets.UTF_8); } - private static void getReadableAxeResults(List results, String type, Element body) { + /** + * Sets up the results into html elements for the report. + * @param results A list of the Rule results found + * @param type The result type that is being created + * @param body The main html page element body + */ + private static void getReadableAxeResults(List results, ResultType type, Element body) { Element resultWrapper = new Element("div"); - resultWrapper.attributes().put(classString, "resultWrapper"); + resultWrapper.attributes().put(CLASS, "resultWrapper"); body.appendChild(resultWrapper); Element sectionButton = new Element("button"); - sectionButton.attributes().put(classString, "sectionbutton active"); + sectionButton.attributes().put(CLASS, "sectionbutton active"); resultWrapper.appendChild(sectionButton); - HashSet selectors = new HashSet<>(); - Element sectionButtonHeader = new Element("h2"); - sectionButtonHeader.attributes().put(classString, "buttonInfoText"); - sectionButtonHeader.text(type + ": " + getCount(results, selectors)); + sectionButtonHeader.attributes().put(CLASS, "buttonInfoText"); + sectionButtonHeader.text(type.name() + ": " + getCount(results)); sectionButton.appendChild(sectionButtonHeader); Element sectionButtonExpando = new Element("h2"); - sectionButtonExpando.attributes().put(classString, "buttonExpandoText"); + sectionButtonExpando.attributes().put(CLASS, "buttonExpandoText"); sectionButtonExpando.text("-"); sectionButton.appendChild(sectionButtonExpando); Element section = new Element("div"); - section.attributes().put(classString, "majorSection"); - section.attributes().put("id", type + "Section"); + section.attributes().put(CLASS, "majorSection"); + section.attributes().put("id", type.name() + "Section"); resultWrapper.appendChild(section); int loops = 1; for (Rule element : results) { Element childEl = new Element("div"); - childEl.attributes().put(classString, "findings"); + childEl.attributes().put(CLASS, "findings"); childEl.appendText(loops++ + ": " + element.getHelp()); section.appendChild(childEl); Element content = new Element("div"); - content.attributes().put(classString, "emTwo"); + content.attributes().put(CLASS, "emTwo"); content.text("Description: " + element.getDescription()); content.appendChild(new Element("br")); content.appendText("Help: " + element.getHelp()); @@ -264,40 +338,128 @@ private static void getReadableAxeResults(List results, String type, Eleme } Element childEl2 = new Element("div"); - childEl2.attributes().put(classString, "emTwo"); + childEl2.attributes().put(CLASS, "emTwo"); childEl.appendChild(content); - for (Node item : element.getNodes()) { + for (CheckedNode item : element.getNodes()) { Element elementNodes = new Element("div"); - elementNodes.attr(classString, "htmlTable"); + elementNodes.attr(CLASS, "htmlTable"); childEl.appendChild(elementNodes); Element htmlAndSelectorWrapper = new Element("div"); - htmlAndSelectorWrapper.attr(classString, "emThree"); + htmlAndSelectorWrapper.attr(CLASS, "emThree"); htmlAndSelectorWrapper.text("Html:"); htmlAndSelectorWrapper.appendChild(new Element("br")); elementNodes.appendChild(htmlAndSelectorWrapper); Element htmlAndSelector = new Element("p"); - htmlAndSelector.attr(classString, "wrapOne"); + htmlAndSelector.attr(CLASS, WRAP_ONE); htmlAndSelector.html(item.getHtml()); htmlAndSelector.text(item.getHtml()); htmlAndSelectorWrapper.appendChild(htmlAndSelector); - htmlAndSelectorWrapper.appendText("Selector(s):"); + htmlAndSelectorWrapper.appendText("Selector:"); htmlAndSelector = new Element("p"); - htmlAndSelector.attributes().put(classString, "wrapTwo"); + htmlAndSelector.attributes().put(CLASS, "wrapTwo"); for (Object target : Collections.singletonList(item.getTarget())) { String targetString = target.toString().replace("[", "").replace("]", ""); htmlAndSelector.text(targetString); htmlAndSelector.html(targetString); } + htmlAndSelectorWrapper.appendChild(htmlAndSelector); + addFixes(item, type, htmlAndSelectorWrapper); } } } + /** + * Add the fixes for the specified result type. + * @param resultsNode The fixes from the results in this specific result type + * @param type The result type fixes + * @param htmlAndSelectorWrapper The element that the fixes will be appended to + */ + private static void addFixes(CheckedNode resultsNode, ResultType type, Element htmlAndSelectorWrapper) { + Element htmlAndSelector = new Element("div"); + + List anyCheckResults = resultsNode.getAny(); + List allCheckResults = resultsNode.getAll(); + List noneCheckResults = resultsNode.getNone(); + + int checkResultsCount = anyCheckResults.size() + allCheckResults.size() + noneCheckResults.size(); + + // Add fixes if this is for violations + if (ResultType.Violations.equals(type) && checkResultsCount > 0) { + htmlAndSelector.text("To solve:"); + htmlAndSelectorWrapper.appendChild(htmlAndSelector); + + htmlAndSelector = new Element("p"); + htmlAndSelector.attr(CLASS, "wrapTwo"); + htmlAndSelectorWrapper.appendChild(htmlAndSelector); + + if (!allCheckResults.isEmpty() || !noneCheckResults.isEmpty()) { + fixAllIssues(htmlAndSelectorWrapper, allCheckResults, noneCheckResults); + } + + if (!anyCheckResults.isEmpty()) { + fixAnyIssues(htmlAndSelectorWrapper, anyCheckResults); + } + } + } + + /** + * Adds the issues in the all category in the list of Checks. + * @param htmlAndSelectorWrapper The element that all the content will be appended to + * @param allCheckResults A list of the all check results + * @param noneCheckResults A list of the none check results + */ + private static void fixAllIssues(Element htmlAndSelectorWrapper, + List allCheckResults, List noneCheckResults) { + Element htmlAndSelector = new Element("p"); + htmlAndSelector.attr(CLASS, WRAP_ONE); + htmlAndSelector.text("Fix at least one of the following issues:"); + + Element htmlSet = new Element("ul"); + + for (var checkResult : allCheckResults) { + Element bulletPoints = new Element("li"); + bulletPoints.text(checkResult.getImpact().toUpperCase() + ": " + checkResult.getMessage()); + htmlSet.appendChild(bulletPoints); + } + + for (var checkResult : noneCheckResults) { + Element bulletPoints = new Element("li"); + bulletPoints.text(checkResult.getImpact().toUpperCase() + ": " + checkResult.getMessage()); + htmlSet.appendChild(bulletPoints); + } + + htmlAndSelector.appendChild(htmlSet); + htmlAndSelectorWrapper.appendChild(htmlAndSelector); + } + + /** + * Adds the issues in the Any category in the list of Checks. + * @param htmlAndSelectorWrapper The element that all the content will be appended to + * @param anyCheckResults A list of the any check results + */ + private static void fixAnyIssues(Element htmlAndSelectorWrapper, List anyCheckResults) { + Element htmlAndSelector = new Element("p"); + htmlAndSelector.attr(CLASS, WRAP_ONE); + htmlAndSelector.text("Fix at least one of the following issues:"); + + Element htmlSet = new Element("ul"); + + for (var checkResult : anyCheckResults) { + Element bulletPoints = new Element("li"); + bulletPoints.text(checkResult.getImpact().toUpperCase() + ": " + checkResult.getMessage()); + htmlSet.appendChild(bulletPoints); + } + + htmlAndSelector.appendChild(htmlSet); + htmlAndSelectorWrapper.appendChild(htmlAndSelector); + } + private static void getContextContent(Results results, Element element) throws ParseException { element.text("Url: " + results.getUrl()); element.appendChild(new Element("br")); @@ -314,15 +476,15 @@ private static void getContextContent(Results results, Element element) throws P + results.getTestEngine().getVersion() + ")"); } - private static int getCount(List results, HashSet uniqueList) { + /** + * Gets the count of the number of rules that came up in the scan. + * @param results The list of rules to be looped through + * @return The count of all the rules + */ + private static int getCount(List results) { int count = 0; for (Rule item : results) { - for (Node node : item.getNodes()) { - for (Object target : Collections.singletonList(node.getTarget())) { - count++; - uniqueList.add(target.toString()); - } - } + count += item.getNodes().size(); // Still add one if no targets are included if (item.getNodes().isEmpty()) { @@ -332,6 +494,15 @@ private static int getCount(List results, HashSet uniqueList) { return count; } + /** + * Sets up the count content for the html report. + * @param violationCount The count for the violations in the scan + * @param incompleteCount The count for incomplete in the scan + * @param passCount The count for passes in the scan + * @param inapplicableCount The count for inapplicable in the scan + * @param requestedResults The result types that will be included on the html report + * @param element The element that all the content will be appended to + */ private static void getCountContent(int violationCount, int incompleteCount, int passCount, int inapplicableCount, Set requestedResults, Element element) { if (requestedResults.contains(ResultType.Violations)) { @@ -354,6 +525,11 @@ private static void getCountContent(int violationCount, int incompleteCount, int } } + /** + * Gets the data image as a base 64 string. + * @param context The web driver or element to take a screenshot of + * @return the base 64 data image as a string + */ private static String getCss(SearchContext context) throws IOException { String css = new String(Files.readAllBytes( Paths.get(resourcesFile + "htmlReporter.css"))); @@ -365,13 +541,18 @@ private static String getDataImageString(SearchContext context) { return "data:image/png;base64," + newScreen.getScreenshotAs(OutputType.BASE64); } + /** + * Gets the date format into a string. + * @param timestamp The time to be made into a date format + * @return The timestamp as a specified date formatted string + * @throws ParseException If parse exception occurs + */ private static String getDateFormat(String timestamp) throws ParseException { Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(timestamp); return new SimpleDateFormat("dd-MMM-yy HH:mm:ss Z").format(date); } private static String getJavascriptFileToString() throws IOException { - return new String(Files.readAllBytes( - Paths.get(resourcesFile + "htmlReporterElements.js"))); + return new String(Files.readAllBytes(Paths.get(resourcesFile + "htmlReporterElements.js"))); } } \ No newline at end of file diff --git a/jmaqs-accessibility/src/test/java/com/magenic/jmaqs/accessibility/AccessibilityHTMLUnitTest.java b/jmaqs-accessibility/src/test/java/com/magenic/jmaqs/accessibility/AccessibilityHTMLUnitTest.java index c5320a1ad..f3d5c2989 100644 --- a/jmaqs-accessibility/src/test/java/com/magenic/jmaqs/accessibility/AccessibilityHTMLUnitTest.java +++ b/jmaqs-accessibility/src/test/java/com/magenic/jmaqs/accessibility/AccessibilityHTMLUnitTest.java @@ -131,7 +131,7 @@ public void accessibilityHtmlReportWithViolation() throws IOException, ParseExce } /** - * Verify we can create an accessibility HTML report file with a lazy element. + * Verify we can create accessibility HTML reports off a lazy element. * @throws IOException if exception is thrown */ @Test(groups = TestCategories.ACCESSIBILITY) @@ -150,7 +150,7 @@ public void accessibilityHtmlReportWithLazyElement() throws IOException, ParseEx } /** - * Verify we can create an accessibility HTML report file off a normal web element. + * Verify we can create accessibility HTML reports off a normal web element. * @throws IOException if exception is thrown */ @Test(groups = TestCategories.ACCESSIBILITY) @@ -212,7 +212,7 @@ public void accessibilityHtmlReportViolationsOnly() throws IOException, ParseExc } /** - * Verify we can create an accessibility HTML report file off a normal web element. + * Verify we can create accessibility HTML reports off a normal web element. * @throws IOException if exception is thrown */ @Test(groups = TestCategories.ACCESSIBILITY) From 7d66712cfbc30e90d16c507c5a50a179ce44227c Mon Sep 17 00:00:00 2001 From: Jon Reding Date: Fri, 15 Oct 2021 15:32:57 -0500 Subject: [PATCH 3/7] Accessibility add fixes (#548) * started work on the add fixes method * resolved issue with nodes/checkedNodes * deleted empty line * import update * update axe version * added comments to HtmlReporter class --- .../jmaqs/accessibility/HtmlReporter.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/HtmlReporter.java b/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/HtmlReporter.java index a4bbfe8eb..e3b9206c7 100644 --- a/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/HtmlReporter.java +++ b/jmaqs-accessibility/src/main/java/com/magenic/jmaqs/accessibility/HtmlReporter.java @@ -460,6 +460,12 @@ private static void fixAnyIssues(Element htmlAndSelectorWrapper, List any htmlAndSelectorWrapper.appendChild(htmlAndSelector); } + /** + * Sets up the Context content and adds it to the element. + * @param results the results to be used for the report + * @param element the element that the content will be added to + * @throws ParseException if an exception is thrown + */ private static void getContextContent(Results results, Element element) throws ParseException { element.text("Url: " + results.getUrl()); element.appendChild(new Element("br")); @@ -526,9 +532,9 @@ private static void getCountContent(int violationCount, int incompleteCount, int } /** - * Gets the data image as a base 64 string. - * @param context The web driver or element to take a screenshot of - * @return the base 64 data image as a string + * Gets the CSS file into a string format. + * @return the CSS file script as a string + * @throws IOException if an exception is thrown */ private static String getCss(SearchContext context) throws IOException { String css = new String(Files.readAllBytes( @@ -536,6 +542,11 @@ private static String getCss(SearchContext context) throws IOException { return css.replace("url('", "url('" + getDataImageString(context)); } + /** + * Gets the data image as a base 64 string. + * @param context The web driver or element to take a screenshot of + * @return the base 64 data image as a string + */ private static String getDataImageString(SearchContext context) { TakesScreenshot newScreen = (TakesScreenshot) context; return "data:image/png;base64," + newScreen.getScreenshotAs(OutputType.BASE64); @@ -552,6 +563,11 @@ private static String getDateFormat(String timestamp) throws ParseException { return new SimpleDateFormat("dd-MMM-yy HH:mm:ss Z").format(date); } + /** + * Gets the javascript file into a string format. + * @return the javascript file script as a string + * @throws IOException if an exception is thrown + */ private static String getJavascriptFileToString() throws IOException { return new String(Files.readAllBytes(Paths.get(resourcesFile + "htmlReporterElements.js"))); } From 97be7e07c3105e4e802f7ca5f40d4df7fa8cfdb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Oct 2021 00:19:16 +0000 Subject: [PATCH 4/7] Bump actions/cache from 2.1.4 to 2.1.6 Bumps [actions/cache](https://github.com/actions/cache) from 2.1.4 to 2.1.6. - [Release notes](https://github.com/actions/cache/releases) - [Commits](https://github.com/actions/cache/compare/v2.1.4...v2.1.6) Signed-off-by: dependabot[bot] --- .github/workflows/pullrequest.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- .github/workflows/snapshot.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index aafef3501..ea6666002 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -19,7 +19,7 @@ jobs: with: java-version: 15 - name: Restore Local Maven Cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 with: path: ~/.m2 key: ${{runner.os}}-m2 @@ -57,7 +57,7 @@ jobs: with: java-version: 11 - name: Restore Local Maven Cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 with: path: ~/.m2 key: ${{runner.os}}-m2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 499ebef43..0f7299999 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,7 +41,7 @@ jobs: with: java-version: 15 - name: Maven Cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 with: path: ~/.m2 key: ${{runner.os}}-m2 @@ -99,7 +99,7 @@ jobs: with: java-version: 15 - name: Maven Cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 with: path: ~/.m2 key: ${{runner.os}}-m2 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index cfc35e2a6..265e11ae1 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -36,7 +36,7 @@ jobs: with: java-version: ${{env.JDK}} - name: Maven Cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 with: path: ~/.m2 key: ${{runner.os}}-m2 @@ -91,7 +91,7 @@ jobs: # with: # java-version: ${{env.JDK}} # - name: Maven Cache -# uses: actions/cache@v2.1.4 +# uses: actions/cache@v2.1.6 # with: # path: ~/.m2 # key: ${{runner.os}}-m2 From 21258588dbe7ce2fafcf150166582902f7e45be8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Oct 2021 03:23:19 +0000 Subject: [PATCH 5/7] Bump GabrielBB/xvfb-action from 1.4 to 1.5 Bumps [GabrielBB/xvfb-action](https://github.com/GabrielBB/xvfb-action) from 1.4 to 1.5. - [Release notes](https://github.com/GabrielBB/xvfb-action/releases) - [Commits](https://github.com/GabrielBB/xvfb-action/compare/v1.4...v1.5) Signed-off-by: dependabot[bot] --- .github/workflows/pullrequest.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/snapshot.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index aafef3501..9e7b57d6e 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -28,7 +28,7 @@ jobs: with: profiles: '[{ "id": "sonar", "properties": { "sonar.organization":"magenic", "sonar.host.url":"https://sonarcloud.io", "sonar.login": "${{secrets.SONAR_LOGIN}}" }}]' - name: Run Unit Tests - uses: GabrielBB/xvfb-action@v1.4 + uses: GabrielBB/xvfb-action@v1.5 with: run: mvn -B -Dtesting verify package --file pom.xml -e -fae -T 1C -Djdk.version=${{matrix.jdk}} env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 499ebef43..22d708c81 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,7 +52,7 @@ jobs: - name: Print out version number from needs run: echo "${{env.VERSION}}" - name: Set Version to ${{env.VERSION}} and Run Unit Tests - uses: GabrielBB/xvfb-action@v1.4 + uses: GabrielBB/xvfb-action@v1.5 with: run: mvn -Drevision="${{env.VERSION}}" -Dtesting -T 1C verify install -B -e -f pom.xml -fae -Djdk.version=${{env.JDK}} env: diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index cfc35e2a6..6f57414ec 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -45,7 +45,7 @@ jobs: with: profiles: '[{ "id": "sonar", "properties": { "sonar.organization":"magenic", "sonar.host.url":"https://sonarcloud.io", "sonar.login": "${{secrets.SONAR_LOGIN}}"}}]' - name: Set Version to ${{env.VERSION}}-SNAPSHOT and Run Unit Tests - uses: GabrielBB/xvfb-action@v1.4 + uses: GabrielBB/xvfb-action@v1.5 with: run: mvn -Drevision="${{env.VERSION}}-SNAPSHOT" -B -Dtesting verify install --file pom.xml -e -fae -T 1C -Djdk.version=${{env.JDK}} env: From 3904d46fbf9567acdcb3ea7afb4759b7112836a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Oct 2021 03:27:03 +0000 Subject: [PATCH 6/7] Bump bruceadams/get-release from 1.2.2 to 1.2.3 Bumps [bruceadams/get-release](https://github.com/bruceadams/get-release) from 1.2.2 to 1.2.3. - [Release notes](https://github.com/bruceadams/get-release/releases) - [Commits](https://github.com/bruceadams/get-release/compare/v1.2.2...v1.2.3) --- updated-dependencies: - dependency-name: bruceadams/get-release dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 499ebef43..006b3a10b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Get release id: get_release - uses: bruceadams/get-release@v1.2.2 + uses: bruceadams/get-release@v1.2.3 env: GITHUB_TOKEN: ${{ github.token }} - name: Formatting Version Tag @@ -41,7 +41,7 @@ jobs: with: java-version: 15 - name: Maven Cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 with: path: ~/.m2 key: ${{runner.os}}-m2 @@ -99,7 +99,7 @@ jobs: with: java-version: 15 - name: Maven Cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 with: path: ~/.m2 key: ${{runner.os}}-m2 From cbd1100eab98e3f3be4adab85e1a0e5c4a347a6f Mon Sep 17 00:00:00 2001 From: Jason Edstrom Date: Thu, 21 Oct 2021 22:34:57 -0500 Subject: [PATCH 7/7] Update pullrequest.yml --- .github/workflows/pullrequest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index ea6666002..73a794ddc 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -65,6 +65,7 @@ jobs: run: mvn -B validate --file pom.xml -e -fae labels: name: Pull Request Labels + if: github.actor != 'dependabot[bot]' runs-on: ubuntu-latest steps: - name: Label Pull Request