i have one textbox on my page on the load event textbox is disable for 10 then its enable so how to wait for 10 sec in watin. i am try to this code
IE ie = new I
Two better ways than just using a long Thread.Sleep() to wait for fields to enable due to a script or asnyc call; eg Ajax. (Note: I'd be ashamed to admit how many long Thread.Sleeps() I have in my code.)
The below are both referencing a checkbox, but the same concepts should work just fine on a textbox or other control.
1) Check the disabled attribute.
myPage.myCheckbox.WaitUntil("disabled", false.ToString())
2) Poll the field, sleeping a short amount of time at each check. I did this poll pattern as the above simple one liner above didn't work; I don't remember why as it has been quite a while.
int sleepTime = 100;
int numberOfPolls = 50;
for (int i = 0; i < 50; i++)
{
if (myPage.myCheckbox.Enabled == false)
{
Thread.Sleep(100);
}
else
{
break;
}
}