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);" ); Selene.SS("a").FindBy(Be.Visible).Click(); Assert.IsTrue(Selene.GetWebDriver().Url.Contains("second")); }
public void WaitForVisibility_OnActionsLikeClick() { Given.OpenedPageWithBody(@" <p> <a href='#second' style='display:none'>go to Heading 2</a> <h2 id='second'>Heading 2</h2> </p>" ); Selene.ExecuteScript(@" setTimeout( function(){ document.getElementsByTagName('a')[0].style = 'display:block'; }, 1000);" ); S("p").Find("a").Click(); Assert.IsTrue(Configuration.Driver.Url.Contains("second")); }
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")); }
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")); }
public void WaitForVisibility_OnActionsLikeClick_AfterSeleneSSWaiting() {// TODO: think on breaking down this test into two, or add one more explicitly testing implicit wait in get // todo: SS can't wait;) something is wrong with the test name;) 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);" ); SS("a")[1].Click(); Assert.IsTrue(Configuration.Driver.Url.Contains("second")); }
public void FailWithTimeout_DuringWaitingForVisibilityOnActionsLikeClick() { 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 InnerSElementSearchFailsOnTimeoutDuringWaitingForVisibilityOnActionsLikeClick() { Configuration.Timeout = 0.25; Given.OpenedPageWithBody(@" <p> <a href='#second' style='display:none'>go to Heading 2</a> <h2 id='second'>Heading 2</h2> </p>" ); Selene.ExecuteScript(@" setTimeout( function(){ document.getElementsByTagName('a')[0].style = 'display:block'; }, 500);" ); try { S("p").Find("a").Click(); Assert.Fail("should fail on timeout before can be clicked"); } catch (WebDriverTimeoutException) { Assert.IsFalse(Selene.GetWebDriver().Url.Contains("second")); } }
public void BothNormalAndInnerSElementSearchWaitsForVisibilityOnActionsLikeClick() { Given.OpenedPageWithBody(@" <p style='display:none'> <a href='#second' style='display:none'>go to Heading 2</a> <h2 id='second'>Heading 2</h2> </p>" ); Selene.ExecuteScript(@" setTimeout( function(){ document.getElementsByTagName('p')[0].style = 'display:block'; }, 500); setTimeout( function(){ document.getElementsByTagName('a')[0].style = 'display:block'; }, 1000);" ); S("p").Find("a").Click(); Assert.IsTrue(Selene.GetWebDriver().Url.Contains("second")); }
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 } }
public static void WithBody(string pageBody) { Selene.ExecuteScript( "document.getElementsByTagName('body')[0].innerHTML = " + PrepareBodyHTML(pageBody) + ";"); }
public static void ExecuteScriptWithTimeout(string js, double timeout) { Selene.ExecuteScript( $"setTimeout(function () {{ {js} }}, {timeout})" ); }