WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Create WinAppDriver session with "app" as currently running client

Open khoachung89 opened this issue 7 years ago • 1 comments

I'm creating a WPF custom control and i need to write UI test for my control with WinAppDriver.

When initialize my test case, i create my window, attach my custom control on that window like: var window = new Window(); var stackPanel = new StackPanel { Orientation = Orientation.Vertical }; stackPanel.Children.Add(new MyCustomWPFControl { Content = "My Custom WPF Control " }); window.Content = stackPanel; window.Show();

The Window and my control will be handle by the thread that running Unit test. Now, after have the Window with my custom control, i wan to create a WinAppDriver session to testing that Window with some options, something like: var option = new AppiumOptions(); option.AddAdditionalCapability("app", "<applicationPath>");

As the running thread that handle the WinAppDriver also handle the Window that need to be test. What value should i put for "app" option of the session? Up to now, i'm using "root" as the whole system UI tree, but it looks not right.

khoachung89 avatar Jul 31 '19 03:07 khoachung89

After several hours of reading, i found a solution. From the window session (the one created with app "root"), we can select the element by window's name and create another session base on that window with "appTopLevelWindow" option.

The answer is got from: https://github.com/Microsoft/WinAppDriver/issues/92#issuecomment-323217558

You may see the example code there too.

khoachung89 avatar Aug 02 '19 08:08 khoachung89