Reputation: 305
I'm waiting for a control to exist, but the test fails before the button exists.
It gives the error: The control is not available or not valid
The code I'm using is:
uIOKButton.WaitForControlExist(2000000);
// Click 'OK' button
Mouse.Click(uIOKButton, new Point(46, 19));
The time out, even though I have it set to 3 hours, times out after 30 mins. So the time out is not working the way it's supposed to. Is there anyway around it?
Is there anyway to stop it from failing other than increasing the timeout?
Upvotes: 2
Views: 11493
Reputation: 688
Try this, before finding the control ID, did the trick for me but it will take some good amount of time. So if you want to load early may be look for the alternative.
BrowserWindow window = new BrowserWindow();
window.WaitForControlExist();
Upvotes: 0
Reputation: 1
Use Timeout
attribute to make any particular test infinite. Also you can specify a certain time if you know that your test will run untill that time.
[Timeout(TestTimeout.Infinite)]
Upvotes: 0
Reputation: 676
what you did originally is the correct way to do it. But after 30 minutes default test timeout pops up.
In your test solution under Solution Items folder find local.testsettings
Double click it, go to timeouts and remove the default timeout of 30 minutes.
Upvotes: 0
Reputation: 1002
I did it like this:
while (!uIItemComboBox.Exists)
{
System.Threading.Thread.Sleep(1000);
}
uIItemComboBox.SelectedItem = this.MyComboBox.UIItemComboBoxSelectedItem;
I'm sure there are nicer ways, but it works.
Upvotes: 1
Reputation: 593
I would suggest you to add a check like:
int count = 1;
while (btnExists() == false){
if (count > 1000) {
//fail test or say that btn is not available
}
count ++;
wait (1);
}
You won't have to wait more than it's required. The test will go on as far as btn becomes available. But make sure to set "count" to have an exit point at some time, in case btn will never appear
Upvotes: 0
Reputation: 38
You can use while loop instead of if statement
The code looks something like this
loopcyle = 1;
While(!uIOKButton.WaitForControlExist(2000) && loopcycle <=20)
{
// Click 'OK' button
Mouse.Click(uIOKButton, new Point(46, 19));
loopcycle ++;
break;
}
Thanks, Karthik KK
Upvotes: 0