microsoft / WinAppDriver

Windows Application Driver
MIT License
3.65k stars 1.4k forks source link

winappdriver - webdriver wait for WPF element #2003

Open xkasjan77 opened 4 months ago

xkasjan77 commented 4 months ago

Hi,

I've created simple methods for locating elements in WPF application. I simply used WebDriverWait which looks like this

try: wait.until(EC.presence_of_element_located((By.ID, element))) except Exception as error: print(error)

The main problem is that when I set time for example 60 seconds and my control show up, script is still looking up for it. Is that normal behaviour of this function? It's pretty same functionality as Time.Sleep(30)

Is there a better usage of wait class for desktop applications?

liljohnak commented 3 months ago

Eventually our code converged to the following:

bool WaitFoSomething(funct<bool> check,int timeout)
{
//while loop to check
}

//usage
Assert.IsTrue(WaitForSomething(EC.FindElementsByAccessibilityId("").Any(),5000), "not there is bad");