Esempio n. 1
0
        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.");
            }
        }
Esempio n. 2
0
        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}"));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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.");
            }
        }
Esempio n. 9
0
        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.");
            }
        }
Esempio n. 10
0
        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);
        }