microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.41k forks source link

The test case does not run again, after it was successfully completed. #743

Open liannah opened 5 years ago

liannah commented 5 years ago

I have created a test case, which was successfully launched. However, after certain time and trying different builts, the test case did not run anymore. I have returned everything back to the way it was running, however no result. The error is as follows: {"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}. I want to imply one more time, that before the application was running without any errors or problems. Any guesses why such issue can occur or any help is greatly appreciated.

riccione commented 5 years ago

Share your code, the error is obvious: driver can not find an element.

liannah commented 5 years ago

Thank you for the reply.

It is a simple code actually, and that is why I did not understand why it can and than after some time cannot run the same code.

[TestMethod] public void Model() { session.FindElementByAccessibilityId("Startup").Click(); session.FindElementByAccessibilityId("bodyPanel").Click(); }

Simple way to create a session, and also I do session.Quit() after each session completed.

DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", EmpAppId); appCapabilities.SetCapability("deviceName", "WindowsPC"); session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1.5));

EmpAppId provided by path.

The problem is that after one successful run the error says it cannot find the element "startup". My best guess after some research is that the application starts the run in the background and thus WInAppDriver fails to recognize the elements.

hassanuz commented 5 years ago

Hi @liannah ,

This sounds like a bug. What kind of application is this (UWP, WinForms, WPF)?

A suggested work around could be adding a sleep timer after session creation, and using SwitchTo to force a switch to the main window handle and have it then come to focus.