1

I am looking to generate simple UI tests for Windows Application, for example launch an application from the start menu and open a file with that said application.

I am looking to allow any user to record a simple UI test as above, I have been looking Microsofts WinAppDriver and yes the driver itself is good for running tests as per samples given from running via test explorer.

I have been looking at the UIrecorder provided within the Git and its seems to fit some of my requirements.

I am currently logging the RecordedUiTask but i don't understand what the C# generated MyDesktopSession object is and how to initialise it in a test.

Example below:

 string xp0 = "/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]/Window[@Name=\"Untitled - Notepad\"][@ClassName=\"Notepad\"]/Document[@Name=\"Text Editor\"][@ClassName=\"Edit\"]";
 var winElem0 = MyDesktopSession.FindElementByXPath(xp0);
 if (winElem0 != null)
 {
     winElem0.Click();
 }

I don't know if there is reasonably priced commercial software available to do this or open source software?

halfer
  • 19,824
  • 17
  • 99
  • 186
user1403598
  • 485
  • 1
  • 6
  • 21
  • I have noticed using the object in my answer below the time to execute a test above is taking around 23 secs for some reason. Any help would be great. – user1403598 Oct 01 '18 at 13:25

3 Answers3

1

You can fork the project to use the official UI Recorder Tool from Microsoft or use the currently latest version from this release.

To inspect objects you can use the inspect.exe that is included in the Windows SDK. You can read this guide to see how to use it.

Schmebi
  • 355
  • 2
  • 16
0

The MyDesktopSession object is defined in the UIRecorderTemplate, which can be found in the Git Repository.

public static WindowsDriver<WindowsElement> DesktopSession;
if (DesktopSession == null)
{
     DesiredCapabilities appCapabilities = new DesiredCapabilities();
     appCapabilities.SetCapability("app", "Root");
     appCapabilities.SetCapability("deviceName", "WindowsPC");
     DesktopSession = new WindowsDriver<WindowsElement>(new 
            Uri(WindowsApplicationDriverUrl), appCapabilities);
}

The object name is different but this provides you with the main object that the UIRecorder utilises.

user1403598
  • 485
  • 1
  • 6
  • 21
0

As for the long run time, you're starting with the Desktop and then drilling down into your AUT. That means that the WHOLE desktop (all running programs) have to be searched to find that field. If you start the search at Notepad, it should go much faster. Here is a answer about selector performance: Selenium Element Selectors - I thought xPath was slowest?

  • 2
    Please include key points from that link in your answer. This will enable future readers to access the content even if the link is removed or changed. – Ishita Sinha Oct 08 '18 at 10:56