public void HomePageWithComplexReport() { string reportPath = Path.Combine(LoggingConfig.GetLogDirectory(), "HomePageWithComplexReport.html"); string rawResults = Path.Combine(LoggingConfig.GetLogDirectory(), "HomePageWithComplexReport.json"); // Get to home page LoginPageModel page = new LoginPageModel(this.TestObject); page.OpenLoginPage(); page.LoginWithValidCredentials(Config.GetGeneralValue("User"), Config.GetGeneralValue("Pass")); // Setup custom rules AxeBuilder builder = new AxeBuilder(WebDriver) .Exclude("#HomePage") .WithOutputFile(rawResults) .DisableRules("landmark-one-main", "page-has-heading-one"); // Reprot WebDriver.CreateAxeHtmlReport(builder.Analyze(), reportPath); // Check if there were any violations if (!File.ReadAllText(reportPath).Contains("Violation: 0")) { TestObject.AddAssociatedFile(reportPath); TestObject.AddAssociatedFile(rawResults); Assert.Fail($"Failed violation check see {reportPath} for more details."); } }
public void ReportSampleResults(string browser) { string path = CreateReportPath(); InitDriver(browser); LoadSimpleTestPage(); Wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector))); JObject jResult = JObject.Parse(File.ReadAllText(IntegrationTestJsonResultFile)); var results = new AxeResult(jResult); WebDriver.CreateAxeHtmlReport(results, path); ValidateReport(path, 3, 5, 2, 4); string text = File.ReadAllText(path); var doc = new HtmlDocument(); doc.LoadHtml(text); var errorMessage = doc.DocumentNode.SelectSingleNode(".//*[@id=\"ErrorMessage\"]").InnerText; Assert.AreEqual("AutomationError", errorMessage); var reportContext = doc.DocumentNode.SelectSingleNode(".//*[@id=\"reportContext\"]").InnerText; Assert.IsTrue(reportContext.Contains($"Url: {results.Url}")); Assert.IsTrue(reportContext.Contains($"Orientation: {results.TestEnvironment.OrientationType}")); Assert.IsTrue(reportContext.Contains($"Size: {results.TestEnvironment.WindowWidth} x {results.TestEnvironment.WindowHeight}")); Assert.IsTrue(reportContext.Contains($"Time: {results.Timestamp}")); Assert.IsTrue(reportContext.Contains($"User agent: {results.TestEnvironment.UserAgent}")); Assert.IsTrue(reportContext.Contains($"Using: {results.TestEngineName} ({results.TestEngineVersion}")); }
public void ReportOnElement(string browser) { string path = CreateReportPath(); InitDriver(browser); LoadSimpleTestPage(); var mainElement = Wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector))); WebDriver.CreateAxeHtmlReport(mainElement, path); ValidateReport(path, 3, 14, 0, 75); }
public void ReportFullPagePassesInapplicableViolationsOnly(string browser) { string path = CreateReportPath(); InitDriver(browser); LoadSimpleTestPage(); Wait.Until(drv => drv.FindElement(By.TagName(mainElementSelector))); WebDriver.CreateAxeHtmlReport(path, ReportTypes.Passes | ReportTypes.Inapplicable | ReportTypes.Violations); ValidateReport(path, 4, 26, 0, 69); ValidateResultNotWritten(path, ReportTypes.Incomplete); }
public void ReportFullPage(string browser) { string path = CreateReportPath(); InitDriver(browser); LoadSimpleTestPage(); Wait.Until(drv => drv.FindElement(By.TagName(mainElementSelector))); WebDriver.CreateAxeHtmlReport(path); ValidateReport(path, 4, 26, 0, 69); }
public void ReportRespectRules(string browser) { string path = CreateReportPath(); InitDriver(browser); LoadSimpleTestPage(); Wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector))); var builder = new AxeBuilder(WebDriver).DisableRules("color-contrast"); WebDriver.CreateAxeHtmlReport(builder.Analyze(), path); ValidateReport(path, 3, 21, 0, 69); }
public void ReportRespectsIframeImplicitTrue(string browser) { string path = CreateReportPath(); string filename = new Uri(Path.GetFullPath(IntegrationTestTargetComplexTargetsFile)).AbsoluteUri; InitDriver(browser); WebDriver.Navigate().GoToUrl(filename); Wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector))); var builder = new AxeBuilder(WebDriver); WebDriver.CreateAxeHtmlReport(builder.Analyze(), path); ValidateReport(path, 4, 43, 0, 64); }
public void LoginSubPageSubElementWithReport() { string reportPath = Path.Combine(LoggingConfig.GetLogDirectory(), "LoginSubPageWithReport.html"); LoginPageModel page = new LoginPageModel(this.TestObject); page.OpenLoginPage(); var jumbotron = WebDriver.FindElement(By.CssSelector(".jumbotron")) as IWrapsElement; WebDriver.CreateAxeHtmlReport(jumbotron.WrappedElement, reportPath); if (!File.ReadAllText(reportPath).Contains("Violation: 0")) { TestObject.AddAssociatedFile(reportPath); Assert.Fail($"Failed violation check see {reportPath} for more details."); } }
public void LoginPageWithReport() { string reportPath = Path.Combine(LoggingConfig.GetLogDirectory(), "LoginPageWithReport.html"); LoginPageModel page = new LoginPageModel(this.TestObject); page.OpenLoginPage(); AxeResult result = WebDriver.Analyze(); WebDriver.CreateAxeHtmlReport(result, reportPath); if (!string.IsNullOrEmpty(result.Error) || result.Violations.Length != 0) { TestObject.AddAssociatedFile(reportPath); Assert.Fail($"Failed error and/or violation check see {reportPath} for more details."); } }
public void ReportRespectsIframeFalse(string browser) { string path = CreateReportPath(); string filename = new Uri(Path.GetFullPath(IntegrationTestTargetComplexTargetsFile)).AbsoluteUri; InitDriver(browser); WebDriver.Navigate().GoToUrl(filename); Wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector))); AxeRunOptions runOptions = new AxeRunOptions { Iframes = false }; var builder = new AxeBuilder(WebDriver).WithOptions(runOptions); WebDriver.CreateAxeHtmlReport(builder.Analyze(), path); ValidateReport(path, 1, 24, 1, 65); }