microsoft / EasyRepro

Automated UI testing API for Dynamics 365
MIT License
513 stars 286 forks source link

[HOW-TO] Checking for "Saving..." overlay instead of using Thinktime or Thread.sleep #1245

Closed MattAtTelstra closed 2 years ago

MattAtTelstra commented 2 years ago

Question

When you click save after creating a new workflow , you get a "Saving..." overlay which can take for our tests anywhere up to 10 seconds to save the workflow, we are trying not to use any sleep or waits in case the saving takes longer.

Does anyone have a different method of checking when that overlay is no longer visible/stopping any interaction with the other buttons?

miiwo commented 2 years ago

I would recommend to use a WebClient method for this: client.Browser.Driver.WaitForTransaction() whenever you see a "Saving..." overlay so that it waits the appropriate amount before continuing on with your program. Cheers!

MattAtTelstra commented 2 years ago

Actually found a great way to fix this this without sleeping:

public void WaitForSavingOverlay() { while (_driver.FindElement(By.Id("mainContent")).GetAttribute("aria-live") == "polite") { Thread.Sleep(100);

        }
    }