Ejemplo n.º 1
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 FilteredSCollectionSearchIsUpdatedOnNextActualActionLikeQuestioiningCount()
        {
            Given.OpenedEmptyPage();
            var elements = Selene.SS("li").FilterBy(Be.Visible);

            When.WithBody(@"
                <ul>Hello to:
                    <li class='will-appear' style='display:none'>Miller</li>
                    <li class='will-appear' style='display:none'>Julie Mao</li>
                </ul>"
                          );
            Assert.AreEqual(0, elements.Count);
            Selene.ExecuteScript(@"
                document.getElementsByTagName('li')[0].style = 'display:block';"
                                 );
            Assert.AreEqual(1, elements.Count);
        }
        public void InnerSElementSearchIsUpdatedOnNextActualActionLikeQuestioiningValue()
        {
            Given.OpenedEmptyPage();
            var element = SS("#will-exist>input").FindBy(Be.Visible);

            When.WithBody(@"
                <p id='will-exist'>
                    <input id='ask' type='submit' value='How r u?' style='display:none'></input>
                    <input id='answer1' type='submit' value='Good!'></input>
                </p>"
                          );
            Assert.AreEqual("Good!", element.Value);
            Selene.ExecuteScript(@"
                document.getElementById('answer1').value = 'Great!';"
                                 );
            Assert.AreEqual("Great!", element.Value);
        }
 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"));
 }
Ejemplo n.º 5
0
        public void InnerSElementSearchIsUpdatedOnNextActualActionLikeQuestioiningValue()
        {
            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);
            When.WithBody(@"
                <p id='existing'>Hello! 
                    <input id='will-exist' type='submit' value='R u Ok?'></input>
                </p>"
                          );
            Assert.AreEqual("R u Ok?", element.Value);
        }
Ejemplo n.º 6
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));
        }
        public void SCollectionSearchIsUpdatedOnNextActualActionLikeQuestioiningCount()
        {
            Given.OpenedEmptyPage();
            var elements = Selene.SS(".will-appear");

            When.WithBody(@"
                <ul>Hello to:
                    <li class='will-appear'>Bob</li>
                    <li class='will-appear'>Kate</li>
                </ul>");
            Assert.AreEqual(2, elements.Count);
            When.WithBody(@"
                <ul>Hello to:
                    <li class='will-appear'>Bob</li>
                    <li class='will-appear'>Kate</li>
                    <li class='will-appear'>Joe</li>
                </ul>");
            Assert.AreEqual(3, elements.Count);
        }
        public void FilteredSCollectionSearchWaitsNothing()
        {
            Given.OpenedEmptyPage();
            var elements = Selene.SS("li").FilterBy(Be.Visible);

            When.WithBodyTimedOut(@"
                <ul>Hello to:
                    <li class='will-appear' style='display:none'>Miller</li>
                    <li class='will-appear' style='display:none'>Julie Mao</li>
                </ul>"
                                  ,
                                  500
                                  );
            When.ExecuteScriptWithTimeout(@"
                document.getElementsByTagName('a')[1].style = 'display:block';
                ", 1000
                                          );
            Assert.AreEqual(0, elements.Count);
        }
        public void SCollectionSearchWaitsNothing()
        {
            Given.OpenedEmptyPage();
            var elements = Selene.SS(".will-appear");

            When.WithBody(@"
                <ul>Hello to:
                    <li class='will-appear'>Bob</li>
                    <li class='will-appear' style='display:none'>Kate</li>
                </ul>"
                          );
            When.WithBodyTimedOut(@"
                <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>",
                                  500
                                  );
            Assert.AreEqual(2, elements.Count);
        }
Ejemplo n.º 10
0
 public void BothSCollectionAndIndexedSElementSearchWaitsForVisibilityOnActionsLikeClick()
 {// TODO: think on breaking down this test into two, or add one more explicitly testing implicit wait in get
     Given.OpenedEmptyPage();
     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"));
 }
Ejemplo n.º 11
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"));
     }
 }
 public void BothSCollectionAndFoundByConditionSElementSearchWaitsForVisibilityOnActionsLikeClick()
 {
     Given.OpenedEmptyPage();
     When.WithBodyTimedOut(@"
         <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>"
                           ,
                           250
                           );
     Selene.ExecuteScript(@"
        setTimeout(
             function(){
                 document.getElementsByTagName('a')[1].style = 'display:block';
             }, 
             500);"
                          );
     SS("a").FindBy(Be.Visible).Click();
     Assert.IsTrue(Selene.Url().Contains("second"));
 }
Ejemplo n.º 13
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"));
            }
        }
Ejemplo n.º 14
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 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
     }
 }
Ejemplo n.º 16
0
 public static void OpenedPageWithBody(string html)
 {
     Given.OpenedEmptyPage();
     When.WithBody(html);
 }
Ejemplo n.º 17
0
 public static void OpenedPageWithBody(string pageBody, IWebDriver driver)
 {
     Given.OpenedEmptyPage(driver);
     When.WithBody(pageBody, driver);
 }
 public void SElementClear()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku'/>");
     Selene.S("input").Clear().Should(Be.Blank);
 }
Ejemplo n.º 19
0
 public void IndexedSElementSearchIsLazyAndDoesNotStartOnCreation()
 {
     Given.OpenedPageWithBody("<p>have no any items</p>");
     var nonExistentElement = Selene.SS(".not-existing")[10];
 }
 public void SElementGetAttribute()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku'/>");
     Assert.AreEqual("text", Selene.S("input").GetAttribute("type"));
 }
 public void SElementGetValue()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku'/>");
     Assert.AreEqual("ku ku", Selene.S("input").Value);
 }
Ejemplo n.º 22
0
 public static void OpenedPageWithBody(string pageBody)
 {
     Given.OpenedEmptyPage();
     When.WithBody(pageBody);
 }
 public void SElementGetCssValue()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku' style='display:none'/>");
     Assert.AreEqual("none", Selene.S("input").GetCssValue("display"));
 }
 public void SElementIsEnabled()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku'/>");
     Assert.AreEqual(true, Selene.S("input").Enabled);
 }
 public void SElementIsDisplayed()
 {
     Given.OpenedPageWithBody("<input type='text' value='ku ku' style='display:none'/>");
     Assert.AreEqual(false, Selene.S("input").Displayed);
 }