This is a migrated thread and some comments may be shown as answers.

Wait.ForCondition - how to use

1 Answer 115 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Wit
Top achievements
Rank 1
Wit asked on 26 Aug 2010, 11:00 AM
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?

1 Answer, 1 is accepted

Sort by
1
Wit
Top achievements
Rank 1
answered on 26 Aug 2010, 11:40 AM
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();
}
Tags
General Discussions
Asked by
Wit
Top achievements
Rank 1
Answers by
Wit
Top achievements
Rank 1
Share this question
or