Beispiel #1
0
 public void SElementShouldBeVisible()
 {
     Given.OpenedPageWithBody("<h1 style='display:none'>ku ku</h1>");
     S("h1").ShouldNot(Be.Visible);
     When.WithBody("<h1 style='display:block'>ku ku</h1>");
     S("h1").Should(Be.Visible);
 }
Beispiel #2
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);
 }
Beispiel #3
0
 public void SElementShouldHaveCssClass()
 {
     Given.OpenedPageWithBody("<h1 class='big-title'>Hello Babe!</h1>");
     S("h1").ShouldNot(Have.CssClass("title"));
     When.WithBody("<h1 class='big title'>Hello world!</h1>");
     S("h1").Should(Have.CssClass("title"));
 }
Beispiel #4
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 InnerSElementSearchIsLazyAndDoesNotStartOnCreation()
        {
            Given.OpenedPageWithBody("<p id='#existing'>Hello!</p>");
            var nonExistentElement = S("#existing").Find("#not-existing-inner");

            Assert.IsNotEmpty(nonExistentElement.ToString());
        }
Beispiel #6
0
        public void IndexedSElementSearchIsLazyAndDoesNotStartEvenOnFollowingInnerSearch()
        {
            Given.OpenedPageWithBody("<p>have no any items</p>");
            var nonExistentElement = Selene.SS(".not-existing")[10].Find("#not-existing-inner");

            Assert.IsNotEmpty(nonExistentElement.ToString());
        }
        public void FoundByConditionSElementSearchIsLazyAndDoesNotStartOnCreation()
        {
            Given.OpenedPageWithBody("<p>have no any items nor visible nor hidden</p>");
            var nonExistentElement = SS(".not-existing").FindBy(Be.Visible);

            Assert.IsNotEmpty(nonExistentElement.ToString());
        }
        public void FoundByConditionSElementSearchIsLazyAndDoesNotStartEvenOnFollowingInnerSearch()
        {//TODO: consider testing using FindBy(Have.CssClass("..."))
            Given.OpenedPageWithBody("<p>have no any items nor visible nor hidden</p>");
            var nonExistentElement = SS(".not-existing").FindBy(Be.Visible).Find("#not-existing-inner");

            Assert.IsNotEmpty(nonExistentElement.ToString());
        }
Beispiel #9
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!"));
 }
Beispiel #10
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);
     });
 }
 public void initPage()
 {
     Given.OpenedPageWithBody(@"
                <h1 name=""greeting"">Hello People!</h1>
                  <ul>Hello to:
                               <li>Dear Bob</li>
                               <li>Dear Frank</li>
                               <li>Lovely Kate</li>
                   </ul>");
 }
        public void InnerSCollectionSearchIsLazyAndDoesNotStartOnCreation()
        {
            Given.OpenedPageWithBody("<p id='#existing'>Hello!</p>");
            var nonExistingCollection = S("#existing").SS(".also-not-existing");

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

            Assert.IsNotEmpty(nonExistingCollection2.ToString());
        }
 public void initPage()
 {
     // NOTE: the Given.RunFromAssemblyLocation = true would create a flash "Your file was not found"
     Given.OpenedPageWithBody(@"
                <h1 name=""greeting"">Hello there!</h1>
                  <ul>Hello to:
                               <li>Dear Bob</li>
                               <li>Dear Frank</li>
                               <li>Lovely Kate</li>
                   </ul>");
 }
Beispiel #14
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 = 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);
        }
 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>"
                              );
     S("p").Find("a").Click();
     Assert.IsTrue(Selene.GetWebDriver().Url.Contains("second"));
 }
Beispiel #17
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"));
 }
Beispiel #18
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);
        }
Beispiel #19
0
 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);"
                          );
     S("a").Click();
     Assert.IsTrue(Selene.GetWebDriver().Url.Contains("second"));
 }
 public void FoundSElementSearchWaitsForItsConditionOnActionsLikeClick()
 {
     Given.OpenedPageWithBody(@"
         <a href='#first' style ='display:none'>go to Heading 1</a>
         <a href='#second' style='display:none'>go to Heading 2</a>
         <h1 id='first'>Heading 1</h1>
         <h2 id='second'>Heading 2</h2>"
                              );
     Selene.ExecuteScript(@"
         setTimeout(
             function(){
                 document.getElementsByTagName('a')[1].style = 'display:block';
             }, 
             250);"
                          );
     SS("a").FindBy(Be.Visible).Click();
     Assert.IsTrue(Selene.GetWebDriver().Url.Contains("second"));
 }
Beispiel #21
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));
        }
Beispiel #22
0
 public void InnerSElementSearchFailsOnTimeoutDuringWaitingForVisibilityOnActionsLikeClick()
 {
     Configuration.Timeout = 0.25;
     Given.OpenedPageWithBody(@"
         <a href='#first'>go to Heading 1</a>
         <a href='#second' style='display:none'>go to Heading 2</a>
         <h1 id='first'>Heading 1</h1>
         <h2 id='second'>Heading 2</h2>"
                              );
     When.ExecuteScriptWithTimeout(@"
         document.getElementsByTagName('a')[1].style = 'display:block';"
                                   ,
                                   500
                                   );
     try {
         Selene.SS("a")[1].Click();
         Assert.Fail("should fail on timeout before can be clicked");
     } catch (WebDriverTimeoutException) {
         Assert.IsFalse(Selene.GetWebDriver().Url.Contains("second"));
     }
 }
Beispiel #23
0
        public void SElementSearchFailsOnTimeoutDuringWaitingForVisibilityOnActionsLikeClick()
        {
            Configuration.Timeout = 0.25;
            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);"
                                 );

            // TODO: consider using Assert.Throws<WebDriverTimeoutException>(() => { ... })
            try {
                S("a").Click();
                Assert.Fail("should fail on timeout before can be clicked");
            } catch (WebDriverTimeoutException) {
                Assert.IsFalse(Selene.GetWebDriver().Url.Contains("second"));
            }
        }
 public void FoundByConditionSElementSearchFailsOnTimeoutDuringWaitingForVisibilityOnActionsLikeClick()
 {
     Configuration.Timeout = 0.25;
     Given.OpenedPageWithBody(@"
         <a href='#first' style='display:none'>go to Heading 1</a>
         <a href='#second' style='display:none'>go to Heading 2</a>
         <h1 id='first'>Heading 1</h1>
         <h2 id='second'>Heading 2</h2>"
                              );
     Selene.ExecuteScript(@"
         setTimeout(
             function(){
                 document.getElementsByTagName('a')[1].style = 'display:block';
             }, 
             500);"
                          );
     try {
         SS("a").FindBy(Be.Visible).Click();
         Assert.Fail("should fail on timeout before can be clicked");
     } catch (WebDriverTimeoutException) {
         Assert.IsFalse(Selene.GetWebDriver().Url.Contains("second"));
         //TODO: consider asserting that actually 250ms passed
     }
 }
Beispiel #25
0
 public void IndexedSElementSearchWaitsForAppearanceOnActionsLikeClick()
 {
     Given.OpenedPageWithBody(@"
         <a href='#first'>go to Heading 1</a>
         <h1 id='first'>Heading 1</h1>
         <h2 id='second'>Heading 2</h2>"
                              );
     When.WithBodyTimedOut(@"
         <a href='#first'>go to Heading 1</a>
         <a href='#second' style='display:none'>go to Heading 2</a>
         <h1 id='first'>Heading 1</h1>
         <h2 id='second'>Heading 2</h2>"
                           , 250
                           );
     Selene.ExecuteScript(@"
         setTimeout(
             function(){
                 document.getElementsByTagName('a')[1].style = 'display:block';
             }, 
             500);"
                          );
     Selene.SS("a")[1].Click();
     Assert.IsTrue(Selene.GetWebDriver().Url.Contains("second"));
 }
 public void SElementIsDisplayed()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku' style='display:none'/>");
     Assert.AreEqual(false, Selene.S("input").Displayed);
 }
 public void SElementIsEnabled()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku'/>");
     Assert.AreEqual(true, Selene.S("input").Enabled);
 }
 public void SElementGetCssValue()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku' style='display:none'/>");
     Assert.AreEqual("none", Selene.S("input").GetCssValue("display"));
 }
Beispiel #29
0
 public void IndexedSElementSearchIsLazyAndDoesNotStartOnCreation()
 {
     Given.OpenedPageWithBody("<p>have no any items</p>");
     var nonExistentElement = Selene.SS(".not-existing")[10];
 }
 public void SElementGetValue()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku'/>");
     Assert.AreEqual("ku ku", Selene.S("input").Value);
 }