Ejemplo n.º 1
0
        public void ShouldPassRunOptions()
        {
            var runOptions = new AxeRunOptions()
            {
                Iframes = true,
                Rules   = new Dictionary <string, RuleOptions>()
                {
                    { "rule1", new RuleOptions()
                      {
                          Enabled = false
                      } }
                }
            };

            var expectedRunOptions = SerializeObject(runOptions);

            SetupVerifiableAxeInjectionCall();
            SetupVerifiableScanCall(null, expectedRunOptions);

            var builder = new AxeBuilder(webDriverMock.Object)
                          .WithOptions(runOptions);

            var result = builder.Analyze();

            VerifyAxeResult(result);

            webDriverMock.VerifyAll();
            targetLocatorMock.VerifyAll();
            jsExecutorMock.VerifyAll();
        }
Ejemplo n.º 2
0
        public void ShouldSerializeRuleOptions()
        {
            var options = new AxeRunOptions()
            {
                Rules = new Dictionary <string, RuleOptions>
                {
                    { "enabledRule", new RuleOptions()
                      {
                          Enabled = true
                      } },
                    { "disabledRule", new RuleOptions()
                      {
                          Enabled = false
                      } },
                    { "rule3WithoutOptionsData", new RuleOptions()
                      {
                      } },
                }
            };
            var expectedObject = "{\"rules\":{\"enabledRule\":{\"enabled\":true},\"disabledRule\":{\"enabled\":false},\"rule3WithoutOptionsData\":{}}}";

            var serializedObject = JsonConvert.SerializeObject(options, serializerSettings);

            serializedObject.Should().Be(expectedObject);
            JsonConvert.DeserializeObject <AxeRunOptions>(expectedObject).Should().BeEquivalentTo(options);
        }
Ejemplo n.º 3
0
        public void ShouldSerializeLiteralTypes()
        {
            var options = new AxeRunOptions()
            {
                AbsolutePaths = true,
                FrameWaitTimeInMilliseconds = 10,
                Iframes       = true,
                RestoreScroll = true,
            };
            var expectedObject = "{\"absolutePaths\":true,\"iframes\":true,\"restoreScroll\":true,\"frameWaitTime\":10}";

            var serializedObject = JsonConvert.SerializeObject(options, serializerSettings);

            serializedObject.Should().Be(expectedObject);
            JsonConvert.DeserializeObject <AxeRunOptions>(expectedObject).Should().BeEquivalentTo(options);
        }
Ejemplo n.º 4
0
        public void ShouldSerializeResultTypes()
        {
            var options = new AxeRunOptions()
            {
                ResultTypes = new HashSet <ResultType>()
                {
                    ResultType.Inapplicable, ResultType.Incomplete, ResultType.Passes, ResultType.Violations
                }
            };

            var serializedObject = JsonConvert.SerializeObject(options, serializerSettings);

            var expectedObject = "{\"resultTypes\":[\"inapplicable\",\"incomplete\",\"passes\",\"violations\"]}";

            serializedObject.Should().Be(expectedObject);
            JsonConvert.DeserializeObject <AxeRunOptions>(expectedObject).Should().BeEquivalentTo(options);
        }
Ejemplo n.º 5
0
        public void ShouldSerializeRunOnlyOption()
        {
            var options = new AxeRunOptions()
            {
                RunOnly = new RunOnlyOptions
                {
                    Type   = "tag",
                    Values = new List <string> {
                        "tag1", "tag2"
                    }
                }
            };

            var serializedObject = JsonConvert.SerializeObject(options, serializerSettings);
            var expectedObject   = "{\"runOnly\":{\"type\":\"tag\",\"values\":[\"tag1\",\"tag2\"]}}";

            serializedObject.Should().Be(expectedObject);
            JsonConvert.DeserializeObject <AxeRunOptions>(expectedObject).Should().BeEquivalentTo(options);
        }
Ejemplo n.º 6
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);
        }