Blazemeter/CitrixPlugin

How to find window title ?

LohithkrishnaGaali opened this issue · 8 comments

Jmeter [5.4.3] with Citrix. Can any of you help how to find the active window name ?
We are able to validate window using window exists but in this case we are giving the window name and checking it.
Is there a assertion or any other method to get the active window name ?

Hi @LohithkrishnaGaali

After any interaction, you can get the value of the window title by attaching a JSR223 Assertion to the interaction with the following Groovy code.

import com.blazemeter.jmeter.citrix.sampler.CitrixSessionHolder;
import com.blazemeter.jmeter.citrix.client.CitrixClient;
import com.blazemeter.jmeter.citrix.client.WindowInfo;

String windowTitle = "";
CitrixClient client = CitrixSessionHolder.getClient();
if (client != null) {
	WindowInfo winInfo = client.getWindowInfos().last();
	if (winInfo != null) {
		windowTitle = winInfo.getCaption();
	}
}
vars.put("ctx_window_title", windowTitle);
return true

After the execution of this code you will have in the variable ctx_window_title the title value of the current window.

Hi @3dgiordano,

I have attached a JSR223 Assertion with above code to the interaction and sometimes able to get the Window title. However, sometimes the above code shows the window title as null in the 'ctx_window_title' variable. Is there any reason for this?

Hi @Madeppa

That information is provided by a Citrix component, not by our plugin.
For some reason the Citrix client component cannot get the caption and the method returns null.
I do not know the reasons, you would have to analyze when it occurs or under what circumstances.
Perhaps by incorporating a retry loop with waits or something similar, you can get the title you want.

Hi @3dgiordano,

Thank you for your reply!!

Every time I execute the script I get different window name. Though the window is active.
I attached a JSR223 Assertion with above code to the Interaction and executed couple of time.

Below is my script steps:

  1. Launch Citrix
  2. Press ctrl+n (here 3 interactions added, for second interaction I have added JSR223 assertion and also added End Clause as Window Gets Foreground as 'New Order')

I have added JSR223 Sampler just to check 'ctx_window_title' variable value with log.info. Here is the code in JSR223 Sampler:
log.info("Window Name is :" + vars.get("ctx_window_title"));

Couple of time I have executed the script, but got 3 different window name. Here actual active window caption is 'New Order'.
However, when I checked in View Result Tree all the time I could see 'New Order' window appeared and its active. Please find below screenshot:

I am struck here to get the current active window name, if this JSR223 assertion code works well all time then we are good to go ahead to build our all citrix scripts in Jmeter.

Do we need to change anything in the JSR223 assertion?

Your response will be much appreciated.

Regards,
Madeppa

Hi @3dgiordano,

Today I did some research by enabling DEBUG in jmeter and found that 'getWindowInfos()' will give all the windows name on current Citrix session.

Added forEach loop to get all windows name and observed that 'getWindowInfos()' wont provide window name in sequentially, it provides all name randomly. Please find below output log:

From above JSR223 Assertion with code 'getWindowInfos().last()' we get the last window caption but it based on the result of getWindowInfos(). Is there a way to fix or get all getWindowInfo sequentially?

Please find below output log:
First:
2023-08-28 03:10:48,298 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@@@@@@@@@@@@@@@@@@@@@ Window titels @@@@@@@@@@@@@@@@@@@@@@@@@
2023-08-28 03:10:48,316 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@@@@@@@@@@@@@@@@@@@@@: client != null
2023-08-28 03:10:48,422 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: New Order
2023-08-28 03:10:48,422 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: UsrLogon.cmd
2023-08-28 03:10:48,422 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: Start Page - SoftPro Select
2023-08-28 03:10:48,423 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: Windows sign-in
2023-08-28 03:10:48,423 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window:

Second:
2023-08-28 03:15:32,843 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@@@@@@@@@@@@@@@@@@@@@ Window titels @@@@@@@@@@@@@@@@@@@@@@@@@
2023-08-28 03:15:32,843 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@@@@@@@@@@@@@@@@@@@@@: client != null
2023-08-28 03:15:32,851 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: ICA Seamless Host Agent
2023-08-28 03:15:32,851 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: Windows sign-in
2023-08-28 03:15:32,851 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: New Order
2023-08-28 03:15:32,851 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window:
2023-08-28 03:15:32,851 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: Start Page - SoftPro Select
2023-08-28 03:15:32,852 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: SplashForm

Third:
2023-08-28 03:20:10,225 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@@@@@@@@@@@@@@@@@@@@@ Window titels @@@@@@@@@@@@@@@@@@@@@@@@@
2023-08-28 03:20:10,226 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@@@@@@@@@@@@@@@@@@@@@: client != null
2023-08-28 03:20:10,227 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: Windows sign-in
2023-08-28 03:20:10,227 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window:
2023-08-28 03:20:10,227 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: Start Page - SoftPro Select
2023-08-28 03:20:10,227 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: New Order

Fourth:
2023-08-28 03:25:25,910 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@@@@@@@@@@@@@@@@@@@@@ Window titels @@@@@@@@@@@@@@@@@@@@@@@@@
2023-08-28 03:25:25,911 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@@@@@@@@@@@@@@@@@@@@@: client != null
2023-08-28 03:25:25,911 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: SplashForm
2023-08-28 03:25:25,912 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: New Order
2023-08-28 03:25:25,912 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: Start Page - SoftPro Select
2023-08-28 03:25:25,912 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window: Windows sign-in
2023-08-28 03:25:25,912 INFO o.a.j.e.J.JSR223 PostProcessor: @@@@@ Window:

Hi @Madeppa

Thanks for reporting that bug to us.
We will take it into consideration to solve it in some future version.

Unfortunately there is no direct solution from outside (JSR223).

What you can try to see if possible is to use the getForegroundWindowArea() method
This returns a java.awt.Rectangle type that is the area of the active window.
You can then iterate through getWindowInfos and see if the areas match using the method getArea() and when match the area, use .getCaption() of which of those windows is the active window.

Unfortunately I don't have a Citrix environment available to test the theory.
I hope the information can be useful and help you.

Hi @Madeppa

A new version of the plugin is available. https://github.com/Blazemeter/CitrixPlugin/releases/tag/0.7.7
The release was already planned, so it did not give me the ability to incorporate a solution for this issue.
But, if I quickly incorporated a method that would allow you to solve what you need.

I update the example code with the new method.

import com.blazemeter.jmeter.citrix.sampler.CitrixSessionHolder;
import com.blazemeter.jmeter.citrix.client.CitrixClient;

String windowTitle = "";
CitrixClient client = CitrixSessionHolder.getClient();
if (client != null) {
	windowTitle = client.getForegroundWindowCaption();
}
vars.put("ctx_window_title", windowTitle);
return true

Let me know if this helps as a workaround while there is no resolution to the problem in the plugin yet.

Hi @3dgiordano,

Thank you so much for you response !!!

I will check the above code with latest Citrix plugin and will let you know.

Regards,
Madeppa