Skip to content

Commit

Permalink
updated ReportType back to ReportTypes due to coding standerds of fla…
Browse files Browse the repository at this point in the history
…g Enum use

Got rid of some code no longer needed
  • Loading branch information
jonreding2010 committed Jan 27, 2021
1 parent 3c2016c commit 67613a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
22 changes: 11 additions & 11 deletions Selenium.Axe/Selenium.Axe.Test/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void ReportFullPage(string browser)
InitDriver(browser);
LoadSimpleTestPage();

var mainElement = _wait.Until(drv => drv.FindElement(By.TagName(mainElementSelector)));
_wait.Until(drv => drv.FindElement(By.TagName(mainElementSelector)));

_webDriver.CreateAxeHtmlReport(path);

Expand All @@ -101,12 +101,12 @@ public void ReportFullPageViolationsOnly(string browser)
InitDriver(browser);
LoadSimpleTestPage();

var mainElement = _wait.Until(drv => drv.FindElement(By.TagName(mainElementSelector)));
_wait.Until(drv => drv.FindElement(By.TagName(mainElementSelector)));

_webDriver.CreateAxeHtmlReport(path, ReportType.Violations);
_webDriver.CreateAxeHtmlReport(path, ReportTypes.Violations);

ValidateReport(path, 4, 0);
ValidateResultNotWritten(path, ReportType.Passes | ReportType.Incomplete | ReportType.Inapplicable);
ValidateResultNotWritten(path, ReportTypes.Passes | ReportTypes.Incomplete | ReportTypes.Inapplicable);
}

[TestMethod]
Expand All @@ -118,11 +118,11 @@ public void ReportFullPagePassesInapplicableViolationsOnly(string browser)
InitDriver(browser);
LoadSimpleTestPage();

var mainElement = _wait.Until(drv => drv.FindElement(By.TagName(mainElementSelector)));
_webDriver.CreateAxeHtmlReport(path, ReportType.Passes | ReportType.Inapplicable | ReportType.Violations);
_wait.Until(drv => drv.FindElement(By.TagName(mainElementSelector)));
_webDriver.CreateAxeHtmlReport(path, ReportTypes.Passes | ReportTypes.Inapplicable | ReportTypes.Violations);

ValidateReport(path, 4, 28, 0, 63);
ValidateResultNotWritten(path, ReportType.Incomplete);
ValidateResultNotWritten(path, ReportTypes.Incomplete);
}

[TestMethod]
Expand Down Expand Up @@ -166,7 +166,7 @@ public void ReportRespectRules(string browser)
string path = CreateReportPath();
InitDriver(browser);
LoadSimpleTestPage();
var mainElement = _wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector)));
_wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector)));

var builder = new AxeBuilder(_webDriver).DisableRules("color-contrast");
_webDriver.CreateAxeHtmlReport(builder.Analyze(), path);
Expand All @@ -182,7 +182,7 @@ public void ReportSampleResults(string browser)
string path = CreateReportPath();
InitDriver(browser);
LoadSimpleTestPage();
var mainElement = _wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector)));
_wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector)));
JObject jResult = JObject.Parse(File.ReadAllText(IntegrationTestJsonResultFile));
var results = new AxeResult(jResult);
_webDriver.CreateAxeHtmlReport(results, path);
Expand Down Expand Up @@ -227,7 +227,7 @@ public void RunSiteThatReturnsMultipleTargets(string browser)
.Select(x => x.Target.Last())
.First();
Assert.IsNotNull(complexTargetNode);
Assert.IsTrue(complexTargetNode.Selectors.Count() == 2);
Assert.IsTrue(complexTargetNode.Selectors.Count == 2);
}

private string CreateReportPath()
Expand Down Expand Up @@ -295,7 +295,7 @@ private void ValidateResultCount(string text, int count, ResultType resultType)
Assert.IsTrue(text.Contains($"{resultType}: {count}"), $"Expected to find '{resultType}: {count}'");
}

private void ValidateResultNotWritten(string path, ReportType ReportType)
private void ValidateResultNotWritten(string path, ReportTypes ReportType)
{
string text = File.ReadAllText(path);

Expand Down
28 changes: 14 additions & 14 deletions Selenium.Axe/Selenium.Axe/HtmlReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Selenium.Axe
/// Findings to include in your HTML
/// </summary>
[Flags]
public enum ReportType
public enum ReportTypes
{
Violations = 1,
Incomplete = 2,
Expand Down Expand Up @@ -65,25 +65,25 @@ public static class HtmlReport
modalimg.alt = thumbnail.alt;
})";

public static void CreateAxeHtmlReport(this IWebDriver webDriver, string destination, ReportType requestedResults = ReportType.All)
public static void CreateAxeHtmlReport(this IWebDriver webDriver, string destination, ReportTypes requestedResults = ReportTypes.All)
{
var axeBuilder = new AxeBuilder(webDriver);
webDriver.CreateAxeHtmlReport(axeBuilder.Analyze(), destination, requestedResults);
}

public static void CreateAxeHtmlReport(this IWebDriver webDriver, IWebElement context, string destination, ReportType requestedResults = ReportType.All)
public static void CreateAxeHtmlReport(this IWebDriver webDriver, IWebElement context, string destination, ReportTypes requestedResults = ReportTypes.All)
{
var axeBuilder = new AxeBuilder(webDriver);
context.CreateAxeHtmlReportFile(axeBuilder.Analyze(context), destination, requestedResults);
}


public static void CreateAxeHtmlReport(this IWebDriver webdriver, AxeResult results, string destination, ReportType requestedResults = ReportType.All)
public static void CreateAxeHtmlReport(this IWebDriver webdriver, AxeResult results, string destination, ReportTypes requestedResults = ReportTypes.All)
{
webdriver.CreateAxeHtmlReportFile(results, destination, requestedResults);
}

private static void CreateAxeHtmlReportFile(this ISearchContext context, AxeResult results, string destination, ReportType requestedResults)
private static void CreateAxeHtmlReportFile(this ISearchContext context, AxeResult results, string destination, ReportTypes requestedResults)
{
// Get the unwrapped element if we are using a wrapped element
context = context is IWrapsElement ? (context as IWrapsElement).WrappedElement : context;
Expand Down Expand Up @@ -175,22 +175,22 @@ private static void CreateAxeHtmlReportFile(this ISearchContext context, AxeResu
}


if (violationCount > 0 && requestedResults.HasFlag(ReportType.Violations))
if (violationCount > 0 && requestedResults.HasFlag(ReportTypes.Violations))
{
GetReadableAxeResults(results.Violations, ResultType.Violations.ToString(), doc, resultsFlex);
}

if (incompleteCount > 0 && requestedResults.HasFlag(ReportType.Incomplete))
if (incompleteCount > 0 && requestedResults.HasFlag(ReportTypes.Incomplete))
{
GetReadableAxeResults(results.Incomplete, ResultType.Incomplete.ToString(), doc, resultsFlex);
}

if (passCount > 0 && requestedResults.HasFlag(ReportType.Passes))
if (passCount > 0 && requestedResults.HasFlag(ReportTypes.Passes))
{
GetReadableAxeResults(results.Passes, ResultType.Passes.ToString(), doc, resultsFlex);
}

if (inapplicableCount > 0 && requestedResults.HasFlag(ReportType.Inapplicable))
if (inapplicableCount > 0 && requestedResults.HasFlag(ReportTypes.Inapplicable))
{
GetReadableAxeResults(results.Inapplicable, ResultType.Inapplicable.ToString(), doc, resultsFlex);
}
Expand Down Expand Up @@ -300,25 +300,25 @@ private static int GetCount(AxeResultItem[] results, ref HashSet<string> uniqueL
return count;
}

private static string GetCountContent(int violationCount, int incompleteCount, int passCount, int inapplicableCount, ReportType requestedResults) {
private static string GetCountContent(int violationCount, int incompleteCount, int passCount, int inapplicableCount, ReportTypes requestedResults) {
StringBuilder countString = new StringBuilder();

if (requestedResults.HasFlag(ReportType.Violations))
if (requestedResults.HasFlag(ReportTypes.Violations))
{
countString.AppendLine($" Violation: {violationCount}<br>");
}

if (requestedResults.HasFlag(ReportType.Incomplete))
if (requestedResults.HasFlag(ReportTypes.Incomplete))
{
countString.AppendLine($" Incomplete: {incompleteCount}<br>");
}

if (requestedResults.HasFlag(ReportType.Passes))
if (requestedResults.HasFlag(ReportTypes.Passes))
{
countString.AppendLine($" Pass: {passCount}<br>");
}

if (requestedResults.HasFlag(ReportType.Inapplicable))
if (requestedResults.HasFlag(ReportTypes.Inapplicable))
{
countString.AppendLine($" Inapplicable: {inapplicableCount}");
}
Expand Down

0 comments on commit 67613a0

Please sign in to comment.