Example #1
0
        public void SearchFailureData_ToStringForNotMissingElement_Empty()
        {
            SearchFailureData data = new SearchFailureData();

            string expected = "Able to locate element that should be missing.";

            Assert.That(data.ToStringForNotMissingElement(), Is.EqualTo(expected));
        }
Example #2
0
        public void SearchFailureData_ToStringForNotMissingElement_ElementName_By()
        {
            SearchFailureData data = new SearchFailureData
            {
                ElementName = "anchor",
                By          = By.XPath(".//a")
            };

            string expected =
                @"Able to locate ""anchor"" element that should be missing:
- By: XPath "".//a""";

            Assert.That(data.ToStringForNotMissingElement(), Is.EqualTo(expected));
        }
Example #3
0
        public void ExceptionFactory_CreateForNotMissingElement()
        {
            SearchFailureData data = new SearchFailureData
            {
                By            = By.XPath(".//a"),
                SearchOptions = SearchOptions.Visible()
            };

            var exception = ExceptionFactory.CreateForNotMissingElement(data);

            string expectedMessage = data.ToStringForNotMissingElement();

            Assert.That(exception.Message, Is.EqualTo(expectedMessage));
        }
Example #4
0
        public void SearchFailureData_ToStringForNotMissingElement_By_SearchOptions_AlikeElementsWithInverseVisibility_2()
        {
            SearchFailureData data = new SearchFailureData
            {
                By            = By.XPath(".//a"),
                SearchOptions = SearchOptions.Visible(),
                AlikeElementsWithInverseVisibility = new[] { new RemoteWebElement(null, null), new RemoteWebElement(null, null) }
            };

            string expected =
                $@"Able to locate visible element that should be missing:
- By: XPath "".//a""
- Search options: {data.SearchOptions}";

            Assert.That(data.ToStringForNotMissingElement(), Is.EqualTo(expected));
        }
Example #5
0
        public void SearchFailureData_ToStringForNotMissingElement_ElementName_By_SearchTime_SearchOptions()
        {
            SearchFailureData data = new SearchFailureData
            {
                ElementName   = "anchor",
                By            = By.XPath(".//a"),
                SearchTime    = TimeSpan.FromSeconds(1.5d),
                SearchOptions = SearchOptions.Hidden()
            };

            string expected =
                $@"Able to locate hidden ""anchor"" element that should be missing:
- By: XPath "".//a""
- Search time: {data.SearchTime.Value.ToShortIntervalString()}
- Search options: {data.SearchOptions}";

            Assert.That(data.ToStringForNotMissingElement(), Is.EqualTo(expected));
        }
Example #6
0
        public void SearchFailureData_ToStringForNotMissingElement_By_SearchContext()
        {
            IWebElement contextElement = StubWebElement.Div;

            SearchFailureData data = new SearchFailureData
            {
                By            = By.XPath(".//a"),
                SearchContext = contextElement
            };

            string expected =
                $@"Able to locate element that should be missing:
- By: XPath "".//a""

Context element:
{contextElement.ToDetailedString()}";

            Assert.That(data.ToStringForNotMissingElement(), Is.EqualTo(expected));
        }