I managed to add a script below to refresh the page if an element is not visible using automation script, and this works but I want it to stop refreshing after a period of time e.g 20 seconds or a number of times if the element is not visible so the test will fail and so it doesn't end up infinitely refreshing. Any advise on how to achieve this with an example please or how to amend the code below to make it work? I tried introducing a timeout to the reloadAsync method but it doesn't accept it.
do
{
await Page.ReloadAsync();
}
while (!await Page.IsVisibleAsync("input[name='elementname']")) ;