Highlighted
Regular Contributor.
Regular Contributor.
1914 views

What is "FlightGuiSampleWpfApp()" in the Flight GUI Sample WPF App code sample?

Jump to solution

Hello,

I am trying to use LeanFT to test the Flight GUI WPF app that comes with UFT.  MicroFocus has provided the code to do this at the location below

https://admhelp.microfocus.com/leanft/en/14.03/HelpCenter/Content/CodeSamples_.NET/CodeEx.NETWPF.htm

Howevere, there is a mention of  FlightGuiSampleWpfApp()) in the code as shown below

using (new FlightGuiSampleWpfApp()) {

I can not find where  FlightGuiSampleWpfApp()) is  defined.

Any ideas?

Thank you.

Burak

 

Tags (3)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Hi,

This application is a WPF application. If the Object identification center shows this as a standard windows application, then it seems like WPF is disabled somehow on your environment.  The first thing I suggest is to open the settings of LeanFT by right clicking on the LeanFT icon and choosing Settings from the menu, and look in the settings for the available add-ins, and veifying the WPF is checked.

I hope this helps

Tsafrir

 

 

View solution in original post

0 Likes
10 Replies
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Hello,

It seems that the code for this class was ommitted from the help center. 

I've contacted LeanfT docs and this will be fixed in the near future.

In the meantime, you can create in your project a new file named FlightGuiSampleWpfApp.cs and paste the following code contents to it, this code is the code for the missing class FlightGuiSampleWpfApp. Please note this code assumes that LeanFT was installed on a 64bit Windows OS in the default location.

I hope this helps.

Regards

Tsafrir

 

The code is (The fomratting needs to be fixed, as the pasted code in here could not be formatted correctly) :

 

using System;
using System.Diagnostics;
using System.Threading;

namespace HP.LeanFT.Examples.WpfFlightSample
{
class FlightGuiSampleWpfApp : IDisposable
{
private readonly Process _sampleFlightGuiWPfAppProcess;

public const int WaitPeriod = 5;

public FlightGuiSampleWpfApp(int seconds = WaitPeriod)
{
_sampleFlightGuiWPfAppProcess = new Process { StartInfo = { FileName = @"C:\Program Files (x86)\HPE\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe" } };
_sampleFlightGuiWPfAppProcess.Start();

Thread.Sleep(seconds * 1000); //Wait for the Flight GUI sample application to be ready since in some cases it takes time to launch on slow machines
}

public void Dispose()
{
_sampleFlightGuiWPfAppProcess.Kill();
_sampleFlightGuiWPfAppProcess.WaitForExit(500);
}

public static void KillAllFlightGUISampleAppInstances()
{
foreach (var p in Process.GetProcessesByName("FlightsGui"))
{
p.Kill();
p.WaitForExit();
}
}

}
}

 

Highlighted
Regular Contributor.
Regular Contributor.

Hi Tsafrir,

I created the class as you wrote and ran this code

[Test]
public void TestWPF_App()
{
using (new FlightGuiSampleWpfApp())
{
// Identify the main Flight GUI sample application window
_flightGUIAapplicationWindow = Desktop.Describe<IWindow>(new WindowDescription
{
// ObjectName = @"HPE MyFlight Sample Application",
// FullType = @"window",
WindowTitleRegExp = @"HPE MyFlight Sample Application"
});
}

PerformLogin();
}

The application popped up but then I got the following error 

HP.LFT.SDK.ReplayObjectNotFoundException : Cannot find the "WPF.IEditField" object's parent "WPF.IWindow" (class WpfWindow).
Verify that parent properties match an object currently displayed in your application.

In the LeanFT documentation,   there is this line

                    WindowTitleRegExp = @"HP MyFlight Sample Application"

but the actual title of the window has an E after HP like this

                    WindowTitleRegExp = @"HPE MyFlight Sample Application"

I tried it both ways, with HP and with HPE but still got the same error.

Any ideas why this might be happening?

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Also, Object Spy is having problems with this app as well.

1) It is only able to highlight and identify the app window and not the username, password  and the buttons on the window.

2) The description for the window

var hPEMyFlightSampleApplicationWindow = Desktop.Describe<IWindow>(new WindowDescription {
IsChildWindow = false,
IsOwnedWindow = false,
WindowClassRegExp = @"HwndWrapper[FlightsGUI.exe;;7ad65225-6adb-4023-988a-f36db6bc96a0]",
WindowTitleRegExp = @"HPE MyFlight Sample Application"
});

throws " "WindowsDescription" does not contain the object [xyz]" error for the lines in red

 

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Hi,

I tried running the code with the following description:

// Identify the Flight GUI main application window. Assign the Flight GUI window to an IWindow object.
_flightGUIAapplicationWindow = Desktop.Describe<IWindow>(new WindowDescription
{
FullType = @"window",
ObjectName = @"HPE MyFlight Sample Application",
WindowTitleRegExp = @"HPE MyFlight Sample Application"

});

Both places were changed to HPE instead of HP, and it worked for me.

Can you please give it a try again with both strings containing HPE as shown above and let us know the outcome?

Thanks!

Tsafrir

 

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Also, regarding the lines

IsChildWindow = false,
IsOwnedWindow = false,
WindowClassRegExp = @"HwndWrapper[FlightsGUI.exe;;7ad65225-6adb-4023-988a-f36db6bc96a0]",

These properties are not part of the properties of WPF windows. Can you please check that in your using statements in the beginning of the cs file, you did not refer to StdWin, WinForms or Java instead of WPF? You should have a using statement of:

 using HP.LFT.SDK.WPF;

In the beginning of your file

 

Thanks

Tsafrir

 

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

I already have the folloiwng line at the top of my page

 using HP.LFT.SDK.WPF;

and I get the error for those three lines.

The weird thing is when I comment out that line and use the StdWin library instead as shown

using HP.LFT.SDK.StdWin;

those errors go away!

The WindowDescription under SydWin has those roperties but the WindowDescription for WPF does not. At least on my version. Here is what I have installed

LeanFT version is 14.03.546.0

Assembly HP.LFT.SDK, Version=14.1.0.0, Culture=neutral, PublicKeyToken=null

How about you?

 

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Also, when I use the Ibject Identification Center to get the window's properties it says

"Standard Windows.Window"

I am launching this GUI application

"C:\Program Files (x86)\HPE\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"

Is this a standrad windows application and not a WPF application? If so, how can I download the WPF application?

Thanks.

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Hi,

The reason theses errors go away when you are using HP.LFT.SDK.StdWin is because these properties are properties that exist only in StdWin Window objects, they are not properties of WPF Window objects. So, this behavior is as expected.

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Hi,

This application is a WPF application. If the Object identification center shows this as a standard windows application, then it seems like WPF is disabled somehow on your environment.  The first thing I suggest is to open the settings of LeanFT by right clicking on the LeanFT icon and choosing Settings from the menu, and look in the settings for the available add-ins, and veifying the WPF is checked.

I hope this helps

Tsafrir

 

 

View solution in original post

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Thank you Tsafrir, checking the WPF option in the LeanFT settings fixed the problem. 🙂

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.