示例#1
0
        public void InnerSCollectionSearchWaitsNothing()
        {
            Given.OpenedEmptyPage();
            var elements = Selene.S("div").SS(".will-appear");

            When.WithBody(@"
                <div>
                    <ul>Hello to:
                        <li class='will-appear'>Bob</li>
                        <li class='will-appear' style='display:none'>Kate</li>
                    </ul>
                </div>"
                          );
            When.WithBodyTimedOut(@"
                <div>
                    <ul>Hello to:
                        <li class='will-appear'>Bob</li>
                        <li class='will-appear' style='display:none'>Kate</li>
                        <li class='will-appear'>Bobik</li>
                    </ul>
                </div>",
                                  500
                                  );
            Assert.AreEqual(2, elements.Count);
        }
        public void SElementSearchIsLazyAndDoesNotStartOnCreation()
        {
            Given.OpenedEmptyPage();
            var nonExistentElement = Selene.S("#not-existing-element-id");

            Assert.IsNotEmpty(nonExistentElement.ToString());
        }
示例#3
0
        public void InnerSCollectionSearchIsUpdatedOnNextActualActionLikeQuestioiningCount()
        {
            Given.OpenedEmptyPage();
            var elements = Selene.S("div").SS(".will-appear");

            When.WithBody(@"
                <div>
                    <ul>Hello to:
                        <li class='will-appear'>Bob</li>
                        <li class='will-appear'>Kate</li>
                    </ul>
                </div>"
                          );
            Assert.AreEqual(2, elements.Count);
            When.WithBody(@"
                <div>
                    <ul>Hello to:
                        <li class='will-appear'>Bob</li>
                        <li class='will-appear'>Kate</li>
                        <li class='will-appear'>Joe</li>
                    </ul>
                </div>"
                          );
            Assert.AreEqual(3, elements.Count);
        }
        public void InnerSElementSearchIsLazyAndDoesNotStartOnCreation()
        {
            Given.OpenedPageWithBody("<p id='#existing'>Hello!</p>");
            var nonExistentElement = Selene.S("#existing").Find("#not-existing-inner");

            Assert.IsNotEmpty(nonExistentElement.ToString());
        }
示例#5
0
 public static void Add(params string[] taskTexts)
 {
     foreach (var text in taskTexts)
     {
         Selene.S("#new-todo").Should(Be.Enabled).SetValue(text).PressEnter();
     }
 }
示例#6
0
 public void SElementShouldBeInDOM()
 {
     Given.OpenedEmptyPage();
     Selene.S("h1").ShouldNot(Be.InDom);
     When.WithBody("<h1 style='display:none'>ku ku</h1>");
     Selene.S("h1").Should(Be.InDom);
 }
示例#7
0
        public void YandexTextSearch()
        {
            String emptySearchResponse = "Задан пустой поисковый запрос";

            Selene.GoToUrl("https://yandex.ru/search");
            Selene.S(With.Text(emptySearchResponse)).Should(Have.Text(emptySearchResponse));
        }
示例#8
0
 public void SElementShouldBeEnabled()
 {
     Given.OpenedPageWithBody("<input type='text' disabled/>");
     Selene.S("input").ShouldNot(Be.Enabled);
     When.WithBody("<input type='text'/>");
     Selene.S("input").Should(Be.Enabled);
 }
示例#9
0
 public void SElementShouldHaveAttribute()
 {
     Given.OpenedPageWithBody("<h1 class='big-title'>Hello Babe!</h1>");
     Selene.S("h1").ShouldNot(Have.Attribute("class", "big title"));
     When.WithBody("<h1 class='big title'>Hello world!</h1>");
     Selene.S("h1").Should(Have.Attribute("class", "big title"));
 }
        public void SElementSearchIsLazyAndDoesNotStartEvenOnFollowingInnerSearch()
        {
            Given.OpenedEmptyPage();
            var nonExistentElement = Selene.S("#not-existing").Find("#not-existing-inner");

            Assert.IsNotEmpty(nonExistentElement.ToString());
        }
示例#11
0
 public void SElementShouldHaveText()
 {
     Given.OpenedPageWithBody("<h1>Hello Babe!</h1>");
     Selene.S("h1").Should(Have.Text("Hello"));
     Selene.S("h1").ShouldNot(Have.Text("Hello world!"));
     Selene.S("h1").ShouldNot(Have.ExactText("Hello"));
     Selene.S("h1").Should(Have.ExactText("Hello Babe!"));
 }
示例#12
0
 public void SElementShouldHaveValue()
 {
     Given.OpenedEmptyPage();
     Selene.S("input").ShouldNot(Have.Value("Yo"));
     When.WithBody("<input value='Yo'></input>");
     Selene.S("input").ShouldNot(Have.Value("o_O"));
     Selene.S("input").Should(Have.Value("Yo"));
 }
        public void SElementSearchIsPostponedUntilActualActionLikeQuestioiningDisplayed()
        {
            Given.OpenedEmptyPage();
            var element = Selene.S("#will-be-existing-element-id");

            When.WithBody(@"<h1 id='will-be-existing-element-id'>Hello kitty:*</h1>");
            Assert.IsTrue(element.Displayed);
        }
        public void GoogleSearchText()
        {
            string url = "http://google.com";

            Selene.GoToUrl(url);
            SeleneElement searchInput = Selene.S("#lst-ib");

            searchInput.SetValue("QA");
        }
示例#15
0
        public void SElementShouldBeVisible()
        {
            Given.OpenedPageWithBody("<h1 style='display:none'>ku ku</h1>");
            Selene.S("h1").ShouldNot(Be.Visible);
            When.WithBody("<h1 style='display:block'>ku ku</h1>");
            var e = Selene.S("h1");

            e.Should(Be.Visible);
        }
示例#16
0
 public void SElelement_ShouldNot_FailsWhenAssertingNotVisibleForVisibleElement()
 {
     Configuration.Timeout = 0.2;
     Given.OpenedPageWithBody("<input id='new-text' type='text' value='ku ku'/>");
     Assert.Throws(Is.TypeOf(typeof(WebDriverTimeoutException))
                   .And.Message.Contains("not " + Be.Visible.GetType().Name), () => {
         Selene.S("#new-text").ShouldNot(Be.Visible);
     });
 }
示例#17
0
 public void SElementShouldBeBlank()
 {
     Given.OpenedEmptyPage();
     Selene.S("input").ShouldNot(Be.Blank);             // TODO: sounds crazy, no? :)
     When.WithBody("<input type='text' value='Yo'/>");
     Selene.S("input").ShouldNot(Be.Blank);
     When.WithBody("<input type='text'/>");
     Selene.S("input").Should(Be.Blank);
 }
        public void SElementSearchWithXpath()
        {
            // find using wrapped driver methods
            IWebDriver  driver  = Selene.GetWebDriver();
            String      xpath   = "//h1[1]";
            IWebElement element = driver.FindElement(By.XPath(xpath));

            Selene.S(With.XPath(xpath)).Should(Be.InDom);
            StringAssert.AreEqualIgnoringCase(Selene.S(With.XPath(xpath)).TagName, element.TagName);
        }
        public void SElementSearchIsUpdatedOnNextActualActionLikeQuestioiningDisplayed()
        {
            Given.OpenedEmptyPage();
            var element = Selene.S("#will-be-existing-element-id");

            When.WithBody(@"<h1 id='will-be-existing-element-id'>Hello kitty:*</h1>");
            Assert.IsTrue(element.Displayed);
            When.WithBody(@"<h1 id='will-be-existing-element-id' style='display:none'>Hello kitty:*</h1>");
            Assert.IsFalse(element.Displayed);
        }
示例#20
0
        public void InnerSCollectionSearchIsLazyAndDoesNotStartOnCreation()
        {
            Given.OpenedPageWithBody("<p id='#existing'>Hello!</p>");
            var nonExistingCollection = Selene.S("#existing").SS(".also-not-existing");

            Assert.IsNotEmpty(nonExistingCollection.ToString());
            var nonExistingCollection2 = Selene.S("#not-existing").SS(".also-not-existing");

            Assert.IsNotEmpty(nonExistingCollection2.ToString());
        }
        public void SElementSearchWithText()
        {
            String      searchText      = "Dear";
            String      xpathSearchText = String.Format(@"//*[contains(text(), ""{0}"")]", searchText);
            IWebDriver  webDriver       = Selene.GetWebDriver();
            IWebElement element         = webDriver.FindElement(By.XPath(xpathSearchText));

            StringAssert.Contains(searchText, element.Text);
            Selene.S(NSelene.With.Text(searchText)).Should(Be.InDom);
            Selene.S(NSelene.With.Text(searchText), webDriver).Should(Be.InDom);
        }
示例#22
0
        public void SElementLocalizedTextSearch()
        {
            String name = "абвгдежзийклмнопрстуфхцчшщъыьэюя";

            Given.OpenedPageWithBody(String.Format("<h1>Hello {0}!</h1>", name));
            Selene.S(With.Text(name)).Should(Have.Text(String.Format("Hello {0}!", name)));
            IWebDriver  driver  = Selene.GetWebDriver();
            IWebElement element = driver.FindElement(By.XPath(String.Format("//h1[contains(text(), '{0}')]", name)));

            StringAssert.AreEqualIgnoringCase("h1", element.TagName);
            Selene.S(With.XPath(String.Format("//h1[contains(text(), '{0}')]", name))).Should(Have.Text(String.Format("Hello {0}!", name)));
        }
        public void InnerSElementSearchIsPostponedUntilActualActionLikeQuestioiningValue()
        {
            Given.OpenedPageWithBody("<p id='existing'>Hello!</p>");
            var element = Selene.S("#existing").Find("#will-exist");

            When.WithBody(@"
                <p id='existing'>Hello! 
                    <input id='will-exist' type='submit' value='How r u?'></input>
                </p>"
                          );
            Assert.AreEqual("How r u?", element.Value);
        }
示例#24
0
        public void FindByCssSelectorAndInnerTextSearch()
        {
            String[] names       = { "Alice", "Bob" };
            String   elementText = String.Format(@"
Hello {0}
and {1}!", names[0], names[1]);

            Given.OpenedPageWithBody(String.Format(@"<h1>{0}</h1>", elementText));
            IWebDriver driver     = Selene.GetWebDriver();
            String     searchText = Regex.Replace(Regex.Replace(elementText, "\r?\n", " "), "^ +", "");

            Selene.S(String.Format("text={0}", searchText)).Should(Be.InDom);
        }
 public void InnerSElementSearchFindsExactlyInsideParentElement()
 {
     Given.OpenedPageWithBody(@"
         <a href='#first' style='display:none'>go to Heading 2</a>
         <p>
             <a href='#second'>go to Heading 2</a>
             <h1 id='first'>Heading 1</h1>
             <h2 id='second'>Heading 2</h2>
         </p>"
                              );
     Selene.S("p").Find("a").Click();
     Assert.IsTrue(Selene.GetWebDriver().Url.Contains("second"));
 }
        public void SElementSearchWithTextResultConditons()
        {
            String      searchText      = "Hello there!";
            String      xpathSearchText = String.Format(@"//*[contains(text(), ""{0}"")]", searchText);
            IWebDriver  webDriver       = Selene.GetWebDriver();
            IWebElement element         = webDriver.FindElement(By.XPath(xpathSearchText));

            StringAssert.Contains(searchText, element.Text);

            // verify can use part of the search text in the condition
            Selene.S(NSelene.With.Text(searchText)).Should(Have.Text("Hello"));
            // verify can use the raw text in assertions - more about it in a dedicated class(es) SElementTextMultiLineSearchTests
            Selene.S(NSelene.With.Text("there!"), webDriver).Should(Have.ExactText(searchText));
            Selene.S(NSelene.With.ExactText(element.Text), webDriver).Should(Have.ExactText(element.Text));
        }
示例#27
0
        public void InnerSCollectionSearchIsPostponedUntilActualActionLikeQuestioiningCount()
        {
            Given.OpenedEmptyPage();
            var elements = Selene.S("div").SS("li");

            When.WithBody(@"
                <div>
                    <ul>Hello to:
                        <li class='will-appear'>Bob</li>
                        <li class='will-appear'>Kate</li>
                    </ul>
                </div>"
                          ); //TODO: consider simplifying example via removing div and using ul instead
            Assert.AreEqual(2, elements.Count);
        }
 public void SElementSearchWaitsForVisibilityOnActionsLikeClick()
 {
     Given.OpenedPageWithBody(@"
         <a href='#second' style='display:none'>go to Heading 2</a>
         <h2 id='second'>Heading 2</h2>"
                              );
     Selene.ExecuteScript(@"
         setTimeout(
             function(){
                 document.getElementsByTagName('a')[0].style = 'display:block';
             }, 
             500);"
                          );
     Selene.S("a").Click();
     Assert.IsTrue(Selene.GetWebDriver().Url.Contains("second"));
 }
        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"));
        }
示例#30
0
        public void SElementMultilineTextSearch()
        {
            String[] names       = { "Alice", "Bob" };
            String   elementText = String.Format(@"
Hello {0}
and {1}!", names[0], names[1]);

            Given.OpenedPageWithBody(String.Format(@"<h1>{0}</h1>", elementText));
            IWebDriver  driver     = Selene.GetWebDriver();
            String      searchText = Regex.Replace(elementText.Replace("\n", " ").Replace("\r", ""), "^ +", "");
            IWebElement element    = driver.FindElement(By.XPath(String.Format("//h1[contains(text(), '{0}')]", searchText)));

            Assert.NotNull(element);
            StringAssert.AreEqualIgnoringCase("h1", element.TagName);
            Selene.S(With.XPath(String.Format("//h1[contains(text(), '{0}')]", searchText))).Should(Be.InDom).Should(Have.Text(String.Format("Hello {0}", names[0])));

            Selene.S(With.Text(names[0])).Should(Have.Text(searchText));
        }