public void SEeleneCollectionSearchWithText()
        {
            String searchText      = "Dear";
            String xpathTextSearch =
                String.Format("//*[contains(text(),'{0}')]", searchText);

            // search using wrapped driver methods

            ReadOnlyCollection <IWebElement> webElements = Selene.GetWebDriver().FindElements(By.XPath(xpathTextSearch));

            Assert.NotNull(webElements);
            Assert.Greater(webElements.Count, 0);
            StringAssert.Contains(searchText, webElements[0].Text);


            // search thru NSelene
            By               seleneLocator   = NSelene.With.Text(searchText);
            IWebDriver       webDriver       = Selene.GetWebDriver();
            SeleneCollection seleWebElements = Selene.SS(seleneLocator);

            Assert.NotNull(seleWebElements);
            Assert.AreEqual(seleWebElements.Count, webElements.Count);
            StringAssert.Contains(searchText, seleWebElements[0].Text);


            // confirm all have searchText
            seleWebElements = Selene.SS(seleneLocator, webDriver);
            Assert.AreEqual(seleWebElements.FilterBy(Have.Text(searchText)).Count, seleWebElements.Count);

            // exercise NSelene extension methods
            Selene.SS(seleneLocator).Should(Have.Texts("Bob", "Frank"));
            Selene.SS(seleneLocator).ShouldNot(Have.Texts("Bob"));
            Selene.SS(seleneLocator).ShouldNot(Have.Texts("Bob", "Kate", "Frank"));
            Selene.SS(seleneLocator).Should(Have.ExactTexts("Dear Bob", "Dear Frank"));
        }
示例#2
0
        public void Complete_Todo()
        {
            Open("http://todomvc.com/examples/emberjs/");
            S("#new-todo").SetValue("a").PressEnter();
            S("#new-todo").SetValue("b").PressEnter();
            S("#new-todo").SetValue("c").PressEnter();

            SS("#todo-list>li").FindBy(Have.ExactText("b")).Find(".toggle").Click();

            SS("#todo-list>li").FilterBy(Have.CssClass("completed")).Should(Have.ExactTexts("b"));
            SS("#todo-list>li").FilterBy(Have.No.CssClass("completed")).Should(Have.ExactTexts("a", "c"));
        }
示例#3
0
 public void SCollectionShouldHaveTextsAndExactTexts()
 {
     Given.OpenedPageWithBody("<ul>Hello to:<li>Dear Bob</li><li>Lovely Kate</li></ul>");
     SS("li").ShouldNot(Have.Texts("Kate", "Bob"));
     SS("li").ShouldNot(Have.Texts("Bob"));
     SS("li").ShouldNot(Have.Texts("Bob", "Kate", "Joe"));
     SS("li").Should(Have.Texts("Bob", "Kate"));
     SS("li").ShouldNot(Have.ExactTexts("Bob", "Kate"));
     SS("li").ShouldNot(Have.ExactTexts("Lovely Kate", "Dear Bob"));
     SS("li").ShouldNot(Have.ExactTexts("Dear Bob"));
     SS("li").ShouldNot(Have.ExactTexts("Dear Bob", "Lovely Kate", "Funny Joe"));
     SS("li").Should(Have.ExactTexts("Dear Bob", "Lovely Kate"));
 }
示例#4
0
        public void FilterTasks()
        {
            Open("https://todomvc4tasj.herokuapp.com/");

            S("#new-todo").SetValue("a").PressEnter();
            S("#new-todo").SetValue("b").PressEnter();
            S("#new-todo").SetValue("c").PressEnter();
            SS("#todo-list>li").Should(Have.ExactTexts("a", "b", "c"));

            SS("#todo-list>li").FindBy(Have.ExactText("b")).Find(".toggle").Click();

            S(By.LinkText("Active")).Click();
            SS("#todo-list>li").FilterBy(Be.Visible).Should(Have.ExactTexts("a", "c"));

            S(By.LinkText("Completed")).Click();
            SS("#todo-list>li").FilterBy(Be.Visible).Should(Have.ExactTexts("b"));
        }
示例#5
0
        public void FiltersTasks()
        {
            Open("https://todomvc4tasj.herokuapp.com/");

            WaitTo(Have.JSReturnedTrue(
                       "return " +
                       "$._data($('#new-todo').get(0), 'events').hasOwnProperty('keyup')&& " +
                       "$._data($('#toggle-all').get(0), 'events').hasOwnProperty('change') && " +
                       "$._data($('#clear-completed').get(0), 'events').hasOwnProperty('click')"));

            S("#new-todo").SetValue("a").PressEnter();
            S("#new-todo").SetValue("b").PressEnter();
            S("#new-todo").SetValue("c").PressEnter();
            SS("#todo-list>li").Should(Have.ExactTexts("a", "b", "c"));

            SS("#todo-list>li").FindBy(Have.ExactText("b")).Find(".toggle").Click();

            S(By.LinkText("Active")).Click();
            SS("#todo-list>li").FilterBy(Be.Visible).Should(Have.ExactTexts("a", "c"));

            S(By.LinkText("Completed")).Click();
            SS("#todo-list>li").FilterBy(Be.Visible).Should(Have.ExactTexts("b"));
        }
        public void SeleneCollectionSearchWithXPath()
        {
            // search using wrapped driver methods
            IWebDriver driver = Selene.GetWebDriver();
            // confirm XPath is valid
            String xpath = "//ul/li";
            ReadOnlyCollection <IWebElement> webElements = driver.FindElements(By.XPath(xpath));

            Assert.NotNull(webElements);
            Assert.Greater(webElements.Count, 0);
            StringAssert.IsMatch("li", webElements[0].TagName);

            // search thru NSelene
            SeleneCollection seleWebElements = null;
            By seleneLocator = With.XPath(xpath);

            seleWebElements = Selene.SS(seleneLocator);
            Assert.NotNull(seleWebElements);
            Assert.AreEqual(seleWebElements.Count, webElements.Count);
            StringAssert.IsMatch("li", seleWebElements[0].TagName);
            // exercise NSelene extension methods
            Selene.SS(seleneLocator).Should(Have.CountAtLeast(1));
            Selene.SS(seleneLocator).Should(Have.ExactTexts("Dear Bob", "Dear Frank", "Lovely Kate"));
        }