Esempio n. 1
0
        public void ExceptionFactory_CreateForNoSuchElement_Null()
        {
            var exception = ExceptionFactory.CreateForNoSuchElement(null);

            string expectedMessage = new SearchFailureData().ToStringForNoSuchElement();

            Assert.That(exception.Message, Is.EqualTo(expectedMessage));
        }
Esempio n. 2
0
        public void ExceptionFactory_CreateForNoSuchElement()
        {
            SearchFailureData data = new SearchFailureData
            {
                By            = By.XPath(".//a"),
                SearchOptions = SearchOptions.Visible()
            };

            var exception = ExceptionFactory.CreateForNoSuchElement(data);

            string expectedMessage = data.ToStringForNoSuchElement();

            Assert.That(exception.Message, Is.EqualTo(expectedMessage));
        }
        public ComponentScopeFindResult Find(ISearchContext scope, ComponentScopeFindOptions options, SearchOptions searchOptions)
        {
            string xPath = BuildXPath(scope, options);

            if (xPath == null)
            {
                if (searchOptions.IsSafely)
                {
                    return(ComponentScopeFindResult.Missing);
                }
                else
                {
                    throw ExceptionFactory.CreateForNoSuchElement(options.GetTermsAsString(), searchContext: scope);
                }
            }

            var xPathOptions = options.Clone();

            xPathOptions.Index = 0;
            xPathOptions.Terms = new[] { xPath };

            return(new SubsequentComponentScopeFindResult(scope, new FindByXPathStrategy(), xPathOptions));
        }
Esempio n. 4
0
        public ComponentScopeLocateResult Find(IWebElement scope, ComponentScopeLocateOptions options, SearchOptions searchOptions)
        {
            string xPath = BuildXPath(scope, options);

            if (xPath == null)
            {
                if (searchOptions.IsSafely)
                {
                    return(new MissingComponentScopeLocateResult());
                }
                else
                {
                    throw ExceptionFactory.CreateForNoSuchElement(options.GetTermsAsString(), searchContext: scope);
                }
            }

            ComponentScopeLocateOptions xPathOptions = options.Clone();

            xPathOptions.Index = 0;
            xPathOptions.Terms = new string[] { xPath };

            return(new SequalComponentScopeLocateResult(scope, new FindByXPathStrategy(), xPathOptions));
        }