コード例 #1
0
        public void SCollectionSearchUsingWithCssAndLegacy()
        {
            String cssSelector = "li";
            // compare with legacy search results
            ReadOnlyCollection <IWebElement> a = Selene.SS(With.Css(cssSelector)).ActualWebElements;
            ReadOnlyCollection <IWebElement> b = Selene.SS(cssSelector).ActualWebElements;

            Assert.AreEqual(a.Intersect(b).Count(), a.Count);
        }
コード例 #2
0
        public void SCollectionSearchWithCss()
        {
            // search using wrapped driver methods
            String     cssSelector = "ul:nth-of-type(1) li";
            IWebDriver driver      = Selene.GetWebDriver();
            ReadOnlyCollection <IWebElement> elements = driver.FindElements(By.CssSelector(cssSelector));

            Assert.NotNull(elements);

            // search thru NSelene
            SeleneCollection sElementCollection = Selene.SS(With.Css(cssSelector), driver);

            Assert.AreEqual(sElementCollection.Count, elements.Count);
        }
コード例 #3
0
        public void SElementSearchWithCss()
        {
            // search using wrapped driver methods
            String      cssSelector = @"h1[name = ""greeting""]";
            IWebDriver  driver      = Selene.GetWebDriver();
            IWebElement element     = driver.FindElement(By.CssSelector(cssSelector));

            StringAssert.IsMatch("greeting", element.GetAttribute("name"));

            // search using NSelene methods
            Selene.S(With.Css(cssSelector), driver).Should(Be.InDom);
            Selene.S(With.Css(cssSelector)).Should(Have.Attribute("name", element.GetAttribute("name")));

            // compare old style and new style search results
            StringAssert.IsMatch(Selene.S(cssSelector).GetAttribute("outerHTML"), Selene.S(With.Css(cssSelector)).GetAttribute("outerHTML"));
        }
コード例 #4
0
        public void MultilineTextSearchIntegrationTest()
        {
            String url         = "http://www.rfbr.ru/rffi/ru/";
            String cssSelector = "div.grants > p";
            // NOTE: The element on the page has a <br/> and a newline
            // removing newline makes the search string one space shorter
            // searchString = "Информация для заявителейи исполнителей проектов";
            // making it difficult to impossible to "predict" the right matching expression
            String searchString = @"Информация для заявителей
и исполнителей проектов";

            Selene.GoToUrl(url);
            // NOTE: slurps exceptions but not in a "Nunit" way
            try {
                // Selene.S(With.Text(searchString)).Should(Be.InDom);
                Selene.S(String.Format("text={0}", searchString.Replace("\n", "").Replace("\r", "")), Selene.GetWebDriver()).Should(Be.InDom);
                // Selene.S(With.Text(searchString)).Should(Have.Text(searchString));
            } catch (TimeoutException e) {
                Console.Error.WriteLine("Exception (ignored) " + e.ToString());
            } catch (NoSuchElementException e) {
                Console.Error.WriteLine("Exception (ignored) " + e.ToString());
            }

            // Break down the element text into single line chunks, successfully find each
            string elementText = (Selene.GetWebDriver()).FindElement(By.CssSelector(cssSelector)).Text;

            elementText = Selene.S(With.Css(cssSelector)).Text;

            foreach (String line in elementText.Split('\n'))
            {
                searchString = line.Replace("\r", "");
                Console.Error.WriteLine("Searching by inner Text fragment:" + searchString);
                Selene.S(With.Text(searchString)).Should(Be.InDom);
                Selene.S(With.Text(searchString)).Should(Have.Text(searchString));
            }
        }
コード例 #5
0
 public void BadCssSelectorArgumentSearch(String expression)
 {
     By css = With.Css(expression);
 }