Wait.ForCondition - how to use

2 posts, 0 answers
  1. Wit
    Wit avatar
    24 posts
    Member since:
    Jul 2010

    Posted 26 Aug 2010 Link to this post

    I can't find anywhere examples for Wait.ForCondition.
    I would like my test to wait for input box to contain text longer than 4 characters.
    How to do it?
  2. Wit
    Wit avatar
    24 posts
    Member since:
    Jul 2010

    Posted 26 Aug 2010 Link to this post

    I think I found some old WebAii documentation that pointed me in the right direction:

    private bool TextBoxHasTextLonger(ArtOfTest.WebAii.Controls.Control control,  object length)
    {
        HtmlInputText textBox = (HtmlInputText)control;
        return textBox.Text.Length>(int)length;
    }
     
    [Test]
    public void Test1()
    {
         
        Manager.LaunchNewBrowser();
        ActiveBrowser.NavigateTo("http://www.skyscanner.net");
         
        SearchPanel sp= Find.ById<SearchPanel>("searchcontrols");
        sp.Departure.TypeText("rzes", 100);
        Desktop.KeyBoard.KeyPress(Keys.Tab); // to leave the box and fire autosuggest completion
         
         
        sp.Destination.TypeText("lond", 100);
        Desktop.KeyBoard.KeyPress(Keys.Tab); // to leave the box and fire autosuggest completion
     
        // wait 5s for autocomplete to fire; text should be longer than typed 4 characters
        sp.Destination.Wait.ForCondition(TextBoxHasTextLonger, false, 4, 5000);
     
        sp.SearchButton.Click();
    }
Back to Top