Code block:
private void SelectRows()
{
var wait = new WebDriverWait(Driver, TimeSpan.FromMilliseconds(500);
// enabling the Rows
this.Page.EnableRowsButton.Click();
wait.Until(_ => this.Page.EnableRowsButton.Checked);
// Sleeping to ensure row exists; I want to use here WebDriverWait so it's faster
Thread.Sleep(500);
// Row modification
foreach (Table.Row row in this.Page.MyTable.Content.Rows)
{
// do stuff
row.CellAt(0).Find<Checkbox>().Click();
}
}
The issue I have is with Thread.Sleep(500);
I am doing this a lot and the time adds up. If I choose it too high my tests run more stable but takes longer to test. If I do it too short my test tends to fail since it wasn't loaded properly.
I want to use WebDriverWait (see in code):
wait.Until(_ => this.Page.EnableRowsButton.Checked);
instead of Thread.Sleep()
to see the Rows are loaded completely.
WebDriverWait wait until it becomes available. So I can choose a bigger duration and it will be shorter if it is sooner available.
Any suggestions?